Created
June 17, 2009 11:23
-
-
Save vjt/131191 to your computer and use it in GitHub Desktop.
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
// Simple tabs implementation that requires the same markup as jQuery UI Tabs, but doesn't modify your | |
// markup or impose an horizontal layout of tabs. You're on your own setting up CSS, of course. Sample | |
// markup: | |
// | |
// <div id="tabs"> | |
// <ul> | |
// <li><a href="#group-1">group 1</a></li> | |
// <li><a href="#group-2">group 2</a></li> | |
// </ul> | |
// <div id="group-1"></div> | |
// <div id="group 2"></div> | |
// </div> | |
// <script type="text/javascript">$('#tabs').simpleTabs();</script> | |
// | |
// Most importantly, the code is so shrunk that it is easily customizable to your needs. | |
// Don't forget: jQuery means "write less, do more"! | |
// - vjt@openssl.it | |
// | |
$.fn.simpleTabs = function() { | |
var container = $(this); | |
var choices = container.children('ul'); | |
var options = arguments[0] || {}; | |
var current = options.current || 'current'; | |
choices.find('li a').click(function() { | |
choices.find('li').removeClass(current); | |
container.children('div').hide(); | |
$(this).parent('li').addClass(current); | |
$($(this).attr('href')).show(); | |
return false; | |
}) | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment