菜单点击事件实例代码
<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>
以上就是菜单点击事件实例代码的详细内容,更多请关注其它相关文章!