Created
April 15, 2014 22:28
-
-
Save ig10/10783762 to your computer and use it in GitHub Desktop.
jQuery simple tabs
This file contains hidden or 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
var Tabs = function(){ | |
function init(){ | |
$('.options > div > a').on('click', function(e){ | |
e.preventDefault(); | |
var $this = $(this); | |
if(!$this.hasClass('active')){ | |
var activeTab = $('.active'); | |
var activeElement = $(activeTab.attr('href')); | |
var triggeredElement = $($this.attr('href')); | |
$this.toggleClass('active'); | |
activeTab.toggleClass('active'); | |
activeElement.toggleClass('shown hidden'); | |
triggeredElement.toggleClass('shown hidden'); | |
} | |
return true; | |
}); | |
} | |
return {init: init}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment