CodeMonkey
CodeMonkey

Reputation: 2295

Bootstrap tabs do not change class when navigating from one tab to other

Here is my fiddle http://jsfiddle.net/codejedi/JJpNz/ . I am trying to change tab color and class when clicked. So far i am able to remove the active class from the button i am migrating from but not able to add active class to the one i am clicking.

Here is my code

$('#headerTab').click(function (e) {
    $('ul.nav-tabs li.active').removeClass('active')
    $(this).parent('li').addClass('active')
})

Upvotes: 0

Views: 165

Answers (1)

chrx
chrx

Reputation: 3572

$('ul.nav-tabs li a').click(function (e) {
    $('ul.nav-tabs li.active').removeClass('active');
    $(this).parent('li').addClass('active');
})

http://jsfiddle.net/JJpNz/3/

Upvotes: 1

Related Questions