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

前端 未结 7 1190
清歌不尽
清歌不尽 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 17:48

    Probably need to just add/subtract classes when you add an external link. It not really bound to the tab at all.

    $(".outside-link").click(function() {
        $(".nav li").removeClass("active");
        $($(this).attr("data-toggle-tab")).parent("li").addClass("active");
    });
    

    Working Fiddle: http://jsfiddle.net/Bp2jm/

提交回复
热议问题