javascript轻松实现当鼠标移开时已弹出子菜单自动消失
作者:互联网
2025-08-18
复制代码代码如下:
< html >
< head >
< style type="text/css" >
.menu
{
background-color:green;
width:120;
height:20;
color: white;
text-align: center;
font-size:9pt;
font-weight:bolder;
}
.submenu
{
position:absolute;
top:40;
background-color:
yellow;width:180;
font-size:9pt;
}
< /style >
< /head >
< body >
< SCRIPT >
var cm=null;
document.onclick = new Function("show(null)")
function getPos(el,sprop)
{var iPos = 0
while (el!=null)
{iPos+=el["offset" + sprop]
el = el.offsetParent}
return iPos}
function show(el,m)
{if (m) { m.style.display='';
m.style.pixelLeft = getPos(el,"Left")
m.style.pixelTop = getPos(el,"Top") + el.offsetHeight}
if ((m!=cm) && (cm)) cm.style.display='none';cm=m}
< /SCRIPT >
< table border=0 >
< tr >
< td ID="d1" onmouseover="show(this,ds1);" >杂志技术站点< /td >
< td ID="d2" onmouseover="show(this,ds2);" >门户站点< /td >
< td ID="d3" onmouseover="show(this,ds3);" >个人收藏站点< /td >
< /tr >
< /table >
< DIV ID="ds1" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'" >
< BR >< A HREF="http://www.**y*esky.com" >天极网 Yesky.com< /A >
< BR >< A HREF="http://www.cbi*n*ew*s.com" >电脑商情报< /A >
< BR >< A HREF="http://www.news*oft.c*o*m.cn" >新潮电子< /A >
< BR >
< /DIV >
< DIV ID="ds2" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'" >
< BR >< A HREF="http://www.**sina*.com.cn" >新浪网 Sina< /A >
< BR >< A HREF="http://www.*sohu.*co*m.cn" >搜狐 Sohu< /A >
< BR >< A HREF="http://www.*1**63.com" >网易 Netease< /A >
< BR >
< /DIV >
< DIV ID="ds3" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'" >
< BR >< A HREF="http://haoel.ye***ah.net" >耗子网络编程站< /A >
< BR >< A HREF="http://www.*5*4*60.net" >中国同学录< /A >
< BR >< A HREF="http://www.c***sdn.net" >中国软件开发网< /A >
< BR >
< /DIV >
< /body >
< /html >
相关标签:
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
AI 打字跟随优化
你的 Vue 3 defineEmits(),VuReact 会编译成什么样的 React?
Vue3 + TS 企业级工程化项目全套实战(Vue3 + Vite + Pinia + VueRouter + Element Plus)
Vue 3 defineOptions 宏,用 VuReact 编译成 React 长什么样?
Vue3 KeepAlive 深度揭秘:组件缓存的魔法是如何实现的?
你的 Vue 3 useAttrs(),VuReact 会编译成什么样的 React?
虚拟 DOM 的 Diff 算法:Vue/React 如何实现高效更新
前端必看!console 调试不只有 log,这 8 个技巧省一半调试时间
在线CAD开发包图纸转换功能使用指南
Vue组件通信全场景详解(Vue2+Vue3适配)| 实战必备,新手也能看懂
AI精选
