jquery each()选项卡

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery选项卡</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<style type="text/css">
      ul{
      margin:0;
      padding:0;
      list-style: none;
      }
      ul li{
      float:left;
      width:80px;
      height:40px;
      background: #eee;
      font-family: "微软雅黑";
      text-align: center;
      line-height: 40px;
      border:3px solid #f0f;
      } 
      #bottom{
      clear:left;
      width:430px;
      height:300px;
      background: #333;
      }
      #bottom div{
      display: none;
      }
      #bottom .bottom-show{  /*不写#bottom会该样式不会执行*/
      display: block;
      font-family: "微软雅黑";
      font-size: 20px;
      color:#f0f;
      }
      .title-show{
      border:3px solid #333;
      }
</style>
</head>
<body>
<div>
<ul id="title">
<li class="title-show">汽车</li>
<li>头条</li>
<li>八卦</li>
<li>娱乐</li>
<li>体育</li>
</ul>
<div id="bottom">
<div class="bottom-show">汽车</div>
<div>头条</div>
<div>八卦</div>
<div>娱乐</div>
<div>体育</div>
</div>
</div>
</body>
<script type="text/javascript">
$(function(){
$("li").each(function(index){
$(this).mouseover(function(){
           $(this).addClass("title-show").siblings().removeClass("title-show");
           $("#bottom>div:eq("+index+")").addClass("bottom-show").siblings().removeClass("bottom-show");
   })
   })
})
</script>

</html>


希望能对需要的人有所帮助

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值