Custom tabs in jquery
How to create custom
tabs in jquery, simple tab in jquery.
Example:
CSS Code:
<style>
.anythingContent{ display: none; border: 1px solid #ccc; padding: 10px;}
.display{ display:block;}
.anythingTabName{ background:#00bbff;}
.anythingTabName
ul{list-style:none;}
.anythingTabName
li{ list-style:none; float:left;}
.anythingTabName
li{color: #fff; text-decoration: none; display: block; padding: 5px 10px;
border-left: 1px solid #878b8f;}
.anythingTabName
li:first-child{ border-left: 0;}
.anythingTabName
li:hover, .anythingTabName li.active{ color:#fff; cursor:pointer; background:#00bb66}
.anythingTabName:after{ clear:both; display:block; content:""}
</style>
HTML Code:
<div class="anythingTabName">
<ul>
<li class="active">Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li>Tab 4</li>
<li>Tab 5</li>
</ul>
</div>
<div class="anythingContent
display"> content 1 content 1 content 1 content 1 content 1 content 1
content 1 content 1 content 1 content 1</div>
<div class="anythingContent"> content 2 content 2
content 2 content 2 content 2 content 2 content 2 content 2 content 2 content 2
content 2</div>
<div class="anythingContent"> content 3 content 3
content 3 content 3 content 3 content 3 content 3 content 3 content 3 content 3
content 3 content 3 content 3 content 3 content 3 content 3 content 3 content 3
content 3 </div>
<div class="anythingContent"> content 4 content 4
content 4 content 4 content 4
content 4 content 4 content 4
content 4 content 4 content 4
content 4 content 4 content 4
content 4 content 4 </div>
<div class="anythingContent"> content 5 content 5
content 5 content 5 content 5
content 5 content 5 content 5
content 5 content 5 content 5
content 5 content 5 content 5
content 5 content 5</div>
Jquery Code:
<script>
jQuery('.anythingTabName ul
li').click(function(){
var num = jQuery(this).index();
jQuery(this).addClass('active').siblings().removeClass('active');
jQuery('.anythingContent:eq('+num+')').show().siblings('.anythingContent').hide();
});
</script>
No comments:
Note: Only a member of this blog may post a comment.