Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Created September 15, 2010 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefrosty/581519 to your computer and use it in GitHub Desktop.
Save thefrosty/581519 to your computer and use it in GitHub Desktop.
// Setting the tabs in the sidebar hide and show, setting the current tab
jQuery('.tab-content').hide();
jQuery('.t1').show();
jQuery('ul.tabs li.t1 a').addClass('tab-current');
jQuery('ul li a').css('cursor','pointer');
jQuery('#tab ul.tabs li.t1 a').click(
function() {
jQuery('#tab div.tab-content').hide();
jQuery('ul.tabs li a').removeClass('tab-current');
jQuery('#tab').find('div.t1').show();
jQuery(this).addClass('tab-current');
}
);
jQuery('#tab ul.tabs li.t2 a').click(
function() {
jQuery('#tab div.tab-content').hide();
jQuery('ul.tabs li a').removeClass('tab-current');
jQuery('#tab').find('div.t2').show();
jQuery(this).addClass('tab-current');
}
);
jQuery('#tab ul.tabs li.t3 a').click(
function() {
jQuery('#tab div.tab-content').hide();
jQuery('ul.tabs li a').removeClass('tab-current');
jQuery('#tab').find('div.t3').show();
jQuery(this).addClass('tab-current');
}
);
jQuery('#tab ul.tabs li.t4 a').click(
function() {
jQuery('#tab div.tab-content').hide();
jQuery('ul.tabs li a').removeClass('tab-current');
jQuery('#tab').find('div.t4').show();
jQuery(this).addClass('tab-current');
}
);
@thefrosty
Copy link
Author

Found my solution:

    $('div.tabbed div').hide();
$('div.t1').show();
$('div.tabbed ul.tabs li.t1 a').addClass('tab-current');
$('div.tabbed ul li a').css('cursor','pointer');

$('div.tabbed ul li a').click(function(){
    var thisClass = this.className.slice(0,2);
    $('div.tabbed div').hide();
    $('div.' + thisClass).show();
    $('div.tabbed ul.tabs li a').removeClass('tab-current');
    $(this).addClass('tab-current');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment