javascript鼠标滑过显示二级菜单特效

前端之家收集整理的这篇文章主要介绍了javascript鼠标滑过显示二级菜单特效前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例为大家分享了javascript鼠标滑过显示二级菜单效果,供大家参考,具体内容如下

1. 关键代码

使用 switch 或 if 判断语句,改变对应的二级菜单显示方式为 block 或 none

2. 主导航 绑定事件

3. 二级菜单

4. 完整代码

水平导航-二级菜单

<script type="text/javascript">
function selectTabMenu(i){
switch(i){
case 71:
document.getElementById("TabMenuCon71").style.display="block";
document.getElementById("TabMenuCon72").style.display="none";
document.getElementById("TabMenuCon73").style.display="none";
document.getElementById("TabMenuCon74").style.display="none";
document.getElementById("TabMenuCon75").style.display="none";
document.getElementById("TabMenuCon76").style.display="none";
break;
case 72:
document.getElementById("TabMenuCon71").style.display="none";
document.getElementById("TabMenuCon72").style.display="block";
document.getElementById("TabMenuCon73").style.display="none";
document.getElementById("TabMenuCon74").style.display="none";
document.getElementById("TabMenuCon75").style.display="none";
document.getElementById("TabMenuCon76").style.display="none";
break;
case 73:
document.getElementById("TabMenuCon71").style.display="none";
document.getElementById("TabMenuCon72").style.display="none";
document.getElementById("TabMenuCon73").style.display="block";
document.getElementById("TabMenuCon74").style.display="none";
document.getElementById("TabMenuCon75").style.display="none";
document.getElementById("TabMenuCon76").style.display="none";
break;
case 74:
document.getElementById("TabMenuCon71").style.display="none";
document.getElementById("TabMenuCon72").style.display="none";
document.getElementById("TabMenuCon73").style.display="none";
document.getElementById("TabMenuCon74").style.display="block";
document.getElementById("TabMenuCon75").style.display="none";
document.getElementById("TabMenuCon76").style.display="none";
break;
case 75:
document.getElementById("TabMenuCon71").style.display="none";
document.getElementById("TabMenuCon72").style.display="none";
document.getElementById("TabMenuCon73").style.display="none";
document.getElementById("TabMenuCon74").style.display="none";
document.getElementById("TabMenuCon75").style.display="block";
document.getElementById("TabMenuCon76").style.display="none";
break;
case 76:
document.getElementById("TabMenuCon71").style.display="none";
document.getElementById("TabMenuCon72").style.display="none";
document.getElementById("TabMenuCon73").style.display="none";
document.getElementById("TabMenuCon74").style.display="none";
document.getElementById("TabMenuCon75").style.display="none";
document.getElementById("TabMenuCon76").style.display="block";
break;
}
}

以上就是本文的全部内容,希望对大家的学习有所帮助。

猜你在找的JavaScript相关文章