Reputation: 3707
I have the following HTML:
<div id="channels">
<ul class="nav nav-tabs" id="ul-channels">
<li class="channel" data-roomid="lobby"><a class="link-channel" href="#lobby" data-toggle="tab">lobby</a></li>
<li class="channel active selected" data-roomid="test"><a class="link-channel" href="#test" data-toggle="tab">test</a></li>
</ul>
</div>
I need an event that occurs when switching tabs. Like this:
$('.nav-tabs a').click(function (e) {
alert("Q");
});
I tried a lot of options, but I had no success. I will appreciate any help.
Upvotes: 18
Views: 43172
Reputation: 3707
The final my solution:
$(document).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
console.log(e.target) // activated tab
})
Upvotes: 43