Jquery Tab 选项卡切换 简单样式(二)

 Jquery Tab 选项卡切换  简单样式(二)

  • 下方效果图和代码
  • copy下来,直接可以使用

 

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Tab简单的选项卡切换</title>
</head>
<style>
.tab-box div{width:927px;height:130px;border:1px solid #000;display:none;}
/* 让第一个框显示出来 */
.tab-box {
    padding-top: 25px;
}
.checkIteam{padding-right: 10px;display:inline-block;}
.tab-box div:first-Child{display:block;}
/* 改变选项卡选中时候的样式 */
.change{background:#70ccf6;}
#tab-lab{
width:130px;height:24px;display:block;float:left;line-height:22px;color:#060606;border:1px solid #000; border-radius:5px 5px 0px 0px;
text-align:center;display:inline-block;
}
</style>
<body>
<table>
      <div class="tab">
          <div class="tab-menu" style="text-align:center;">
                  <lable id="tab-lab" name="doctype" value="0" onmouseover=mymouse(this)>无</lable>
                  <lable id="tab-lab" name="doctype" value="2" onmouseover=mymouse(this)>新闻中心</lable>
                  <lable id="tab-lab" name="doctype" value="3" onmouseover=mymouse(this)>评测中心</lable>
                  <lable id="tab-lab" name="doctype" value="1" onmouseover=mymouse(this)>行情中心</lable>
                  <lable id="tab-lab" name="doctype" value="4" onmouseover=mymouse(this)>导购中心</lable>
          </div>
          <div class="tab-box">
              <div>靠!奥巴马来我家了!!!^……^</div>
              <div>听说,你昨天去整容了,小伙!</div>
              <div>我昨天中了一个亿的彩票!</div>
	      <div>昨天梦见好多好多鱼,在我的床上游来游去!</div>
         </div>
      </div>
</table>
</body>
</html>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
    // 获取默认选中的元素的下标
    var _index=$("lable[checked='checked']").index();
      // console.log($(this).html());
    //让内容框的第 _index 个显示出来,其他的被隐藏
    $(".tab-box>div").eq(_index).show().siblings().hide();
//改变选中时候的选项框的样式,移除其他几个选项的样式
  $("lable[checked='checked']").addClass("change").siblings().removeClass("change");
  // $(this).addClass("change").siblings().removeClass("change");
})

  function mymouse(id){
          var _index = $(id).index();
      //让内容框的第 _index 个显示出来,其他的被隐藏
      $(".tab-box>div").eq(_index).show().siblings().hide();
      //改变选中时候的选项框的样式,移除其他几个选项的样式
      $(".tab-menu>lable").eq(_index).addClass("change").siblings().removeClass("change");
      $(".tab-menu>lable").eq(_index).attr("checked","checked").siblings().removeAttr("checked");
      // var _checkinde = $("lable[checked='checked']").attr("value");
      // return _checkinde;

 }
</script>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值