Reputation: 719
I setup a fiddle here: http://jsfiddle.net/bnnsqwsd/.
Basically, I'm trying to recreate http://jsfiddle.net/syahrasi/Us8uc/, but with a couple changes (changing from ids to data-attributes mostly, so I can have multiple tab modules on a page).
It works, but if you click the first active tab (Tab #1) after the load, it breaks?
Here's my jQuery:
$(document).ready(function() {
$(".tabs-menu a").click(function(event) {
event.preventDefault();
$(this).parent().addClass("current");
$(this).parent().siblings().removeClass("current");
var tab = $(this).data("tab");
$(".tab-content").not(tab).css("display", "none");
$(tab).fadeIn();
});
});
Upvotes: 0
Views: 90
Reputation: 287
i also use this tab. it nice and small script. i want to how can make auto change one by one. say like each 5 sec next tab will active. something like slider
Upvotes: 0
Reputation: 196002
You need to change the first tabs link to
<a href="#" data-tab=".tab-1">Tab 1</a>
demo at http://jsfiddle.net/bnnsqwsd/2/
Upvotes: 1
Reputation: 24001
you forget to Add
data-tab=".tab-1"
to your first li a
<li class="current"><a href="#tab-1" data-tab=".tab-1">Tab 1</a></li>
Upvotes: 3