码迷,mamicode.com
首页 > Web开发 > 详细

利用jquery eq()属性的tab栏

时间:2018-09-18 17:26:50      阅读:496      评论:0      收藏:0      [点我收藏+]

标签:addclass   ble   ali   oct   set   .com   port   tab   splay   

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.tab {
margin: 200px;
}
 
.tab-bay {
overflow: hidden;
}
 
ul li {
list-style: none;
float: left;
margin: 0 20px;
}
 
.tab-item {
height: 30px;
width: 40px;
text-align: center;
line-height: 30px;
background: #666;
color: #fff;
}
 
.active {
color: red;
}
 
.conter-son {
background: pink;
}
 
.conter-sona {
display: none;
text-align: center;
}
 
.conter-sonactive {
display: block;
}
</style>
</head>

<body>
<div class="tab">
<ul class="tab-bay">
<li class="tab-item active">tab1</li>
<li class="tab-item">tab2</li>
<li class="tab-item">tab3</li>
<li class="tab-item">tab4</li>
</ul>
<div class="conter-son">
<div class="conter-sona conter-sonactive">
<span>1</span>
</div>
<div class="conter-sona">
<span>2</span>
</div>
<div class="conter-sona">
<span>3</span>
</div>
<div class="conter-sona">
<span>4</span>
</div>
</div>
</div>

<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
<script>
$(function() {
$(‘.tab-bay .tab-item‘).click(function() {
$(this).addClass(‘active‘).siblings().removeClass(‘active‘);
$(‘.conter-son .conter-sona‘).eq($(this).index()).show().siblings().hide();
});
});
</script>
</body>

</html>

利用jquery eq()属性的tab栏

标签:addclass   ble   ali   oct   set   .com   port   tab   splay   

原文地址:https://www.cnblogs.com/caihuan99/p/9669682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!