Last active
December 22, 2015 00:59
-
-
Save juanbrujo/6393260 to your computer and use it in GitHub Desktop.
Fast tabs with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-- TABS --*/ | |
var tabMenu = '.nav'; | |
var tabContent = '.destacadas'; | |
var tabSelectedClass= 'selected'; | |
var tabDefault = 1; // first tab | |
// add classes and hiding tabs | |
$(tabMenu+' a:eq('+(tabDefault-1)+')').addClass(tabSelectedClass); | |
$(tabContent).hide(); | |
$(tabContent+':eq('+(tabDefault-1)+')').show(); | |
// connecting the dots | |
$(tabMenu+' a').on('click',function(e){ | |
e.preventDefault(); | |
var activeTab = $(this).attr('href'); | |
$(tabMenu+' a').removeClass(tabSelectedClass); | |
$(this).addClass(tabSelectedClass); | |
$(tabContent).hide(); | |
$(activeTab).fadeIn('fast'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment