Bootstrap:url或链接到打开标签并展开手风琴

时间:2013-07-11 17:58:17

标签: jquery twitter-bootstrap tabs accordion

我已经找到JS来扩展特定的手风琴......

$(document).ready(function () {
location.hash && $(location.hash + '.collapse').collapse('show');
});

或者打开特定标签...

var gotoHashTab = function (customHash) {
 var hash = customHash || location.hash;
 var hashPieces = hash.split('?'),
  activeTab = $('[href=' + hashPieces[0] + ']');
  activeTab && activeTab.tab('show');
}

// onready go to the tab requested in the page hash
gotoHashTab();

// when the nav item is selected update the page hash
$('.nav a').on('shown', function (e) {
    window.location.hash = e.target.hash;
})

// when a link within a tab is clicked, go to the tab requested
$('.tab-pane a').click(function (event) {
    if (event.target.hash) {
        gotoHashTab(event.target.hash);
    }
});

与一个看起来像这样的链接或网址一起使用......

http://mysite.com/page#tab_or_accordion_id

我希望能够做的是打开特定的标签ID,然后展开特定的手风琴ID。我想使用它来进行特定的分类(带标签)FAQ的文章内跳转。我似乎无法弄清楚如何将它们拼接在一起以使其工作。 考虑一下我使用jQuery和Bootstrap的新手 - 非常感谢任何帮助。

0 个答案:

没有答案