Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap tab callback event

I want to add my custom function every time after change tabs.

<ul class="nav nav-tabs">
    <li class>
        <div>
            <a href="#logo"></a>
        </div>
    </li>
    <li class = "active"></li>
    <li class></li>
</ul>

<div id="logo"></div>
like image 740
S.P Avatar asked Nov 28 '22 13:11

S.P


1 Answers

You should use the show.bs.tab and shown.bs.tab listeners:

$('.nav-tabs').find('a').on('show.bs.tab', function () {
    // Some code you want to run when tab is clicked (before the tab is shown)
});

$('.nav-tabs').find('a').on('shown.bs.tab', function () {
    // Some code you want to run after the tab is shown (callback)
});

Other options and listeners available here: W3Schools bootsrap tabs

like image 161
Ali Elkhateeb Avatar answered Dec 04 '22 11:12

Ali Elkhateeb