javascript輕松實現(xiàn)當(dāng)鼠標(biāo)移開時已彈出子菜單自動消失
更新時間:2013年12月29日 16:27:05 作者:
本文為大家詳細(xì)介紹下使用javascript實現(xiàn)當(dāng)鼠標(biāo)移開時已彈出子菜單自動消失,具體如下,感興趣的朋友不要錯過
復(fù)制代碼 代碼如下:
<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);" class="menu">雜志技術(shù)站點</td>
<td ID="d2" onmouseover="show(this,ds2);" class="menu">門戶站點</td>
<td ID="d3" onmouseover="show(this,ds3);" class="menu">個人收藏站點</td>
</tr>
</table>
<DIV ID="ds1" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >天極網(wǎng) Yesky.com</A>
<BR><A >電腦商情報</A>
<BR><A >新潮電子</A>
<BR>
</DIV>
<DIV ID="ds2" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >新浪網(wǎng) Sina</A>
<BR><A >搜狐 Sohu</A>
<BR><A >網(wǎng)易 Netease</A>
<BR>
</DIV>
<DIV ID="ds3" CLASS="submenu" STYLE="display:none" onmouseleave="this.style.display='none'">
<BR><A >耗子網(wǎng)絡(luò)編程站</A>
<BR><A >中國同學(xué)錄</A>
<BR><A >中國軟件開發(fā)網(wǎng)</A>
<BR>
</DIV>
</body>
</html>
相關(guān)文章
Firefox+FireBug使JQuery的學(xué)習(xí)更加輕松愉快
FireBug是FireFox下最強(qiáng)大的調(diào)試插件.利用它,可以讓JQuery的學(xué)習(xí)過程更加輕松愉快.2010-01-01
javascript RadioButtonList獲取選中值
js獲取RadioButtonList值的代碼。2009-04-04
微信小程序中的canvas 文字?jǐn)嘈泻褪÷蕴栵@示功能的處理方法
大家都知道在canvas中沒有提供方法來處理文字的多行問題,只有通過截取指定字符串來達(dá)到目的。接下來通過本文給大家介紹微信小程序中的canvas 文字?jǐn)嘈泻褪÷蕴栵@示功能 ,需要的朋友可以參考下2018-11-11

