Skip to content

Instantly share code, notes, and snippets.

@paulgosnell
Created October 11, 2011 10:08
Show Gist options
  • Save paulgosnell/1277755 to your computer and use it in GitHub Desktop.
Save paulgosnell/1277755 to your computer and use it in GitHub Desktop.
Simple tabs using hash
$(function() {
var tabContent = $(".tab_content");
// Modified tutorial's code for this
var tabs = $("ul#tabsNav li");
var hash = window.location.hash;
tabContent.not(hash).hide();
tabs.find('[href=' + hash + ']').addClass('active');
tabs.click(function() {
$(this).addClass('active').siblings().removeClass('active');
tabContent.hide();
var activeTab = $(this).find("a")[0].hash;
$(activeTab).fadeIn();
return false;
});
$(".tab_content:first").show(); //Show first tab content
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment