Skip to content

Instantly share code, notes, and snippets.

@Neolot
Last active October 12, 2015 03:28
Show Gist options
  • Save Neolot/3964393 to your computer and use it in GitHub Desktop.
Save Neolot/3964393 to your computer and use it in GitHub Desktop.
JQUERY Tabs
.tabs-wrapper .box {display: none;}
.tabs-wrapper .box.visible {display: block;}
<div class="tabs-wrapper">
<ul class="tabs clearfix">
<li class="current">Tab #1</li>
<li>Tab #2</li>
</ul>
<div class="box visible">Tab #1 Content</div>
<div class="box">Tab #2 Content</div>
</div>
$('ul.tabs').each(function() {
$(this).find('li').each(function(i) {
$(this).click(function() {
$(this).addClass('current').siblings().removeClass('current');
var p = $(this).parents('div.tabs-wrapper');
p.find('div.box').hide();
p.find('div.box:eq(' + i + ')').fadeToggle('fast');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment