Skip to content

Instantly share code, notes, and snippets.

@zurie
Created February 19, 2015 15:23
Show Gist options
  • Save zurie/7c81748527164b7b5ca7 to your computer and use it in GitHub Desktop.
Save zurie/7c81748527164b7b5ca7 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabbed-content li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabbed-content li").click(function() {
$("ul.tabbed-content li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment