Bootstrap 3 jquery event for active tab change

前端 未结 6 1458
挽巷
挽巷 2020-11-28 17:22

I spent an unrealistic amount of time trying to fire a function when the tab changes of the bootstrap 3 tab/navbar and literally all suggestions google spat out wer

6条回答
  •  感动是毒
    2020-11-28 18:25

    $(function () {
        $('#myTab a:last').tab('show');
    });
    
    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        var target = $(e.target).attr("href");
        if ((target == '#messages')) {
            alert('ok');
        } else {
            alert('not ok');
        }
    });
    

    the problem is that attr('href') is never empty.

    Or to compare the #id = "#some value" and then call the ajax.

提交回复
热议问题