Reputation: 21
I am using simple tab ;created using css.
I have current class to show currently active tab . i am managing using jquery
$(".Tabs").click(function(){
$(this).addClass('current ');
});
This works fine but it does not remove class from previously activated tab . Please help
Upvotes: 1
Views: 37
Reputation: 1004
You can use the following code:
$(".Tabs").click(function(){
$(this).addClass('current');
$(".Tabs").not($(this)).removeClass('current');
});
Upvotes: 1
Reputation: 5135
This is because you are not removing the current class from the previous active tab.
You can do this by removing the current
class from the previous like follows:
$(".Tabs").click(function(){
$(this).parent().find('current ').removeClass('current');
$(this).addClass('current ');
});
Upvotes: 1
Reputation: 8584
Try removing the class from siblings:
$(".Tabs").click(function(){
$(this).siblings().removeClass("current").addClass('current');
});
Upvotes: 0