监听的事件具体,这样不会联动
<ul>
<li class="two">
<a><h3>啦啦啦</h3></a>
<ul class="three">
<li class="five">啦啦啦</li>
<li class="five">啦啦啦</li>
<li class="five">啦啦啦</li>
</ul>
</li>
<li class="two">
<a><h3>哦哦哦</h3></a>
<ul class="three">
<li class="five">啦啦啦</li>
<li class="five">啦啦啦</li>
<li class="five">啦啦啦</li>
</ul>
</li>
</ul>
<style>
li {
list-style: none;
}
.active {
color: blue;
}
.activee {
color: red;
}
.three {
display: none;
}
</style>
主要代码内容
<script>
$('.two>a').click(function () {
$(this).parent().addClass('active').siblings().removeClass('active');
var three = $(this).parent().find('ul');
if (three.css('display') == 'none') {
three.show();
}else {
three.hide();
}
});
$('.five').click(function (){
$(this).addClass('activee').siblings().removeClass('activee');
})
</script>
以上就是菜单点击事件实例代码的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号