jQuery - Easy Tabs


/ Published in: jQuery
Save to your folder(s)

easy tabs


Copy this code and paste it in your HTML
  1. //Default Action
  2. $(".tab-content").hide(); //Hide all content
  3. $("ul.tabs li:first").addClass("active").show(); //Activate first tab
  4. $(".tab-content:first").show(); //Show first tab content
  5.  
  6. //On Click Event
  7. $("ul.tabs li").click(function() {
  8. $("ul.tabs li").removeClass("active"); //Remove any "active" class
  9. $(this).addClass("active"); //Add "active" class to selected tab
  10. $(".tab-content").hide(); //Hide all tab content
  11. var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
  12. $(activeTab).fadeIn(); //Fade in the active content
  13. return false;
  14. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.