<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="box/jquery/jquery-3.3.1.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
a{
text-decoration: none;
color: black;
}
li{
list-style: none;
}
.selectcolor{
color: white;
}
.selectnone{
color: black;
}
.left-menu ul{
width: 100px;
background-color: gray;
}
.left-menu ul li{
width: 100px;
line-height: 50px;
text-align: center;
color: black;
}
.left-menu ul li ul li {
display: none;
}
</style>
<script>
$(function(){
// 二级菜单显示隐藏
$(".one").click(function(){
$(this).next().find("li").slideToggle();
$(this).parent().nextAll().find("ul").find("li").slideUp();
$(this).parent().prevAll().find("ul").find("li").slideUp();
});
})
</script>
</head>
<body>
<div class="left-menu">
<ul>
<li>
<a href="javascript:void(0)" class="one">1</a>
<ul>
<li><a href="javascript:void(0)">1-1</a></li>
<li><a href="javascript:void(0)">1-2</a></li>
<li><a href="javascript:void(0)">1-3</a></li>
</ul>
</li>
<li>
<a href="javascript:void(0)" class="one">2</a>
<ul>
<li><a href="javascript:void(0)">2-1</a></li>
<li><a href="javascript:void(0)">2-2</a></li>
<li><a href="javascript:void(0)">2-3</a></li>
</ul>
</li>
<li>
<a href="javascript:void(0)" class="one">3</a>
<ul>
<li><a href="javascript:void(0)">3-1</a></li>
<li><a href="javascript:void(0)">3-2</a></li>
<li><a href="javascript:void(0)">3-3</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
jquery多级菜单
最新推荐文章于 2023-09-06 11:44:59 发布