Linking to a Bootstrap Tab from outside - how to set the tab to “active”?

前端 未结 7 1134
清歌不尽
清歌不尽 2020-12-01 17:10

I have a Bootstrap \"tab\" navigation with 3 different content tabs. It works perfectly except that I want to link to one of the tabs from OUTSIDE the tab navigation. Meanin

相关标签:
7条回答
  • 2020-12-01 18:02

    I had the same issue, and opted to just trigger a click event on the proper tab, and let Bootstrap do what is needed.

    $('#link').on('click', function(){
      $('.nav-tabs a[href="#profile"]').click();
    });
    
    0 讨论(0)
提交回复
热议问题