Skip to content

Instantly share code, notes, and snippets.

@Grawl
Forked from patrickberkeley/jquery.tabs.js
Last active December 22, 2015 21:29
Show Gist options
  • Save Grawl/6533711 to your computer and use it in GitHub Desktop.
Save Grawl/6533711 to your computer and use it in GitHub Desktop.
Simple and easy to use tabs with jQuery
$(document).ready(function(){
$(".tabs-menu li:first, .tabs-content:first").addClass("active");
$(".tabs-content:not(:first)").hide();
$(".tabs-menu > li > a").click(function(e){
var index = $('.tabs-menu li').index($(this).parent('li'));
$('.tabs-menu li.active, .tabs-content.active').removeClass('active');
$(this).parent('li').addClass('active');
$('.tabs-content').hide();
$('.tabs-content').eq(index).show();
return false;
});
});
mixin tabs(tabs)
-for tab in tabs
li: a(href="javascript:")=tab
+tabs(["First", "Second", "Third"])
.tabs-content
First
.tabs-content
Second
.tabs-content
Third
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment