<!DOCTYPE html>
<html>
<body>
<style>
.title_tab li {
float: left;
list-style: none outside none;
}
.content_tab li {
display: none;
list-style: none outside none;
}
.title_tab ul {
height: 30px;
margin: 0;
padding: 0;
}
.title_tab li a {
background: none repeat scroll 0 0 #D7D7D7;
border-radius: 5px 5px 0 0;
border-top: 1px solid #CCCCCC;
color: #666161;
display: block;
font-family: arial;
margin-left: 10px;
padding: 5px 33px;
text-decoration: none;
}
.content_tab li {
}
.content_tab li.active {
display: block;
}
.content_tab > ul {
background: none repeat scroll 0 0 #EDEDED;
border-radius: 4px;
margin: 0;
padding: 10px;
}
.title_tab li.active a {
background: none repeat scroll 0 0 #EDEDED;
color: #060606;
font-weight: bold;
}
</style>
<div class="title_tab">
<ul class="">
<li data-class-child="1" class="active"> <a href="#">1</a></li>
<li data-class-child="2"> <a href="#">2</a></li>
<li data-class-child="3"> <a href="#">3</a></li>
</ul>
</div>
<div class="content_tab">
<ul class="">
<li class="active"> <a href="#">a</a></li>
<li> <a href="#">b</a></li>
<li> <a href="#">c</a></li>
</ul>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.title_tab li').click(function(event) {
var pos_li=$(this).attr('data-class-child');
$('.title_tab ul>li').removeClass('active');
$(this).addClass('active');
$('.content_tab ul>li').removeClass('active');
$('.content_tab ul>li:nth-child('+pos_li+')').addClass('active');
return false;
});;
});
</script>
</body>
</html>
Không có nhận xét nào:
Đăng nhận xét