Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink

前端 未结 24 1941
夕颜
夕颜 2020-11-22 04:57

I\'m developing a web page in which I\'m using Twitter\'s Bootstrap Framework and their Bootstrap Tabs JS. It works great except for a few minor issues, one of which is I do

24条回答
  •  感动是毒
    2020-11-22 05:10

    Combining peices from other answers, here is a solution that can open many levels of nested tabs:

    // opens all tabs down to the specified tab
    var hash = location.hash.split('?')[0];
    if(hash) {
      var $link = $('[href=' + hash + ']');
      var parents = $link.parents('.tab-pane').get();
      $(parents.reverse()).each(function() {
        $('[href=#' + this.id + ']').tab('show') ;
      });
      $link.tab('show');
    }
    

提交回复
热议问题