当前位置:编程学习 > JAVA >>

jQuery 复习之选项卡 简洁代码

<html>
<head>

<script src='js/min.js'></script>
<script src='js/card.js'></script>


</head>


<body>
<div class="tab">
<div class="tab_menu">
<ul>
<li class="tab_selected">时事</li>
<li>体育</li>
<li>娱乐</li>
</ul>
</div>
<div class="tab_content">
<div>时事</div>
<div class="hide">体育</div>
<div class="hide">娱乐</div>
</div>
</div>
</body>

 

</html>

 


$(function(){


$('.tab_menu li').click(function(){

$(this).css({'background':'red'}).siblings().css({'background':''});

$('.tab_content div').eq($(this).index()).show().siblings().hide();

});

 

 

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,