Skip to content

Instantly share code, notes, and snippets.

@paveltyk
Created April 20, 2011 13:13
Show Gist options
  • Save paveltyk/931300 to your computer and use it in GitHub Desktop.
Save paveltyk/931300 to your computer and use it in GitHub Desktop.
jQuery simple tabs
$('ul.tab-controls li').bind('click', function() {
$(this).addClass('active').siblings().removeClass('active')
.parents('#funbox').find('ul.tab').hide().eq($(this).index()).fadeIn(500);
return false;
});
// HTML:
// <div id="funbox">
// <ul class="tab-controls">
// <li class="active"><a href="#">Featured</a></li>
// <li><a href="#">Popular</a></li>
// <li><a href="#">Archives</a></li>
// </ul>
// <ul class="tab"><li>Hello from the first tab</li></ul>
// <ul class="tab"><li>Hello from the second tab</li></ul>
// </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment