Skip to content

Instantly share code, notes, and snippets.

@ig10
Created April 15, 2014 22:28
Show Gist options
  • Save ig10/10783762 to your computer and use it in GitHub Desktop.
Save ig10/10783762 to your computer and use it in GitHub Desktop.
jQuery simple tabs
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