当前位置 : 主页 > 网页制作 > JQuery >

jquery写二级菜单

来源:互联网 收集:自由互联 发布时间:2021-06-15
!DOCTYPE html html head meta charset="utf-8" title/title style type="text/css" ul ul {display: none;} /style /head body ul class="nav" li span一级菜单/span ul li二级菜单/li li二级菜单/li li二级菜单/li li二级菜单/li li二级

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
ul ul {display: none;}
</style>
</head>
<body>
<ul class="nav">
<li>
<span>一级菜单</span>
<ul>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ul>
</li>
<li>
<span>一级菜单</span>
<ul>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ul>
</li>
<li>
<span>一级菜单</span>
<ul>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ul>
</li>
</ul>
</body>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(".nav").children("li").mouseover(function(){
$(this).children("ul").stop().show(500)
.parent().siblings().children("ul").stop().hide(500);
})
</script>
</html>
<!-- 次jQuery为第一代14版 -->

网友评论