<ul style="display: none" id="ul1">
<li><a href="/agent/Order.asp" data-original-title="子菜单1"><span class="hidden-minibar "> 子菜单1</span></a></li>
<li><a href="/agent/OrderBuy.asp" data-original-title="子菜单2"><span class="hidden-minibar "> 子菜单2</span></a></li>
<li><a href="/agent/tkinfo.asp" data-original-title="子菜单3"><span class="hidden-minibar "> 子菜单3</span></a></li>
</ul>
</li>
<li class="submenu"><a class="dropdown " href="javascript:showMenu(2)" data-original-title="主菜单2"><span aria-hidden="true" class="icon icon-magnifier-add"></span><span class="hidden-minibar "> 主菜单2</span><span class="fa arrow"></span></a>
<ul style="display: none" id="ul2">
<li><a href="/agent/Order.asp" data-original-title="子菜单1"><span class="hidden-minibar "> 子菜单1</span></a></li>
<li><a href="/agent/OrderBuy.asp" data-original-title="子菜单2"><span class="hidden-minibar "> 子菜单2</span></a></li>
<li><a href="/agent/tkinfo.asp" data-original-title="子菜单3"><span class="hidden-minibar "> 子菜单3</span></a></li>
</ul>
</li>
<script>
function showMenu(s){
if(s == 1){
document.getElementById("ul1").style.display="block"
document.getElementById("ul2").style.display="none"
}else if(s == 2){
document.getElementById("ul2").style.display="block"
document.getElementById("ul1").style.display="none"
}
}
</script>
这样就行了
其实思路很容易的,先做大导航。然后做下拉菜单,但是下拉菜单默认是display:none当鼠标指向上边的大导航的项目的时候(mouseover),对应的下拉菜单的CSS样式中的display属性设置为block,mouseout的时候又置为none;<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>
RunJS 演示代码
</title>
<script>
jQuery(function($){
$("ul>li>a").click(function(){
$(this).next("ul").toggle().closest("li").siblings("li").children("ul").hide()
}).next("ul").hide()
})
</script>
</head>
<body>
<ul>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
</ul>
</body>
</html>