Reputation: 367
I want to make a check on nav tabs. If current tab for example $('.nav-tabs li:eq(3) a.active')
is active then alert("3");
if tab no 4 then alert("4");
. Any help would be nice.
my try
if($('.nav-tabs li:eq(3) a.active'))
{
alert("3");
}
Upvotes: 2
Views: 4763
Reputation: 61083
Bootstrap (I assume you're using v3) has event callbacks that you may employ:
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
e.target // activated tab
e.relatedTarget // previous tab
})
http://getbootstrap.com/javascript/#tabs
You could do what you're asking for like this:
alert( $(e.target).closest('li').index() + 1 );
http://jsfiddle.net/isherwood/aHXm4/
In response to your comment:
http://jsfiddle.net/isherwood/aHXm4/2
if ($(e.target).closest('li').index() + 1 == 3) {
var save = "jack";
alert(save);
}
Upvotes: 9