Skip to content

Instantly share code, notes, and snippets.

@joshuapaling
Created July 15, 2013 04:02
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 joshuapaling/5997421 to your computer and use it in GitHub Desktop.
Save joshuapaling/5997421 to your computer and use it in GitHub Desktop.
Super Simple JQuery Tabs
function setUpTabs($tabContainer){
$('.tab_links a', $tabContainer).click(function(){
$('.tab_content', $tabContainer).hide();
$('.tab_links a', $tabContainer).removeClass('current');
$(this).addClass('current');
var tabId = $(this).attr('href');
//tabId = tabId.substr(1); // stip of the # from the front
window.location.hash = tabId;
$(tabId).show();
return false;
});
$firstTab = $('.tab_links a', $tabContainer).first();
$('.tab_content', $tabContainer).hide();
$firstTab.trigger('click');
}
setUpTabs($('.my_tabs_container'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment