Created
May 5, 2011 16:08
-
-
Save patrickberkeley/957331 to your computer and use it in GitHub Desktop.
jQuery Tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// Take care of the initial page load | |
$(".tabs-menu li:first, .tabs-content:first").addClass("active"); | |
$(".tabs-content:not(:first)").hide(); | |
// Capture clicks on the tabs menu. Set the clicked menu item | |
// to active. Show the corresponding | |
// content block (by index) and hide all others. | |
$(".tabs-menu > li > a").click(function(e){ | |
var index = $('.tabs-menu li').index($(this).parent('li')); | |
$('.tabs-menu li.active, .tabs-content.active').removeClass('active'); | |
$(this).parent('li').addClass('active'); | |
$('.tabs-content').hide(); | |
$('.tabs-content').eq(index).show(); | |
return false; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%ul.tabs-menu | |
%li | |
%a{:href=>"javascript:void(0)"} First | |
%li | |
%a{:href=>"javascript:void(0)"} Second | |
%li | |
%a{:href=>"javascript:void(0)"} Third | |
.tabs-content | |
First content... | |
.tabs-content | |
Second content... | |
.tabs-content | |
Third content... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple and easy to use. thank you.