首页 文章

深层链接Jquery选项卡

提问于
浏览
0

我正在寻找一个插件/示例/教程,它将向我展示如何深层链接jquery选项卡和嵌套选项卡 . 有谁知道我在哪里可以找到这样的例子?我想将其添加到网站,但我不知道从哪里开始 .

2 回答

  • 2

    Asual jquery地址插件应该为你排序,很多例子http://www.asual.com/jquery/address/或github https://github.com/asual/jquery-address

    或者你可以尝试ben alman的jquery bbq插件

    希望有所帮助!

  • 1

    使用'select'方法的所有解决方案都不适用于更高版本的jquery选项卡 . 现在通过将选项active设置为选项卡的所需int(偏移量为0)来完成 . 而且这个功能比jQuery地址插件更轻量级(虽然不是全功能) .

    function initTabs() {
    var tabIndex = {'yourTabID-1':0,'yourTabID-2':1,'yourTabID-3':2}
    var re = /#\w+$/; // This will match the anchor tag in the URL i.e. http://here.com/page#anchor
    var match = re.exec(document.location.toString());
    match = location.hash;
    if (match != null) var anchor = match.substr(1);
    for (key in tabIndex) {
        if (anchor == key) {
            selectedTab = tabIndex[key];
            break;
        }
    else selectedTab = 0;
    }
    $( "#tabs" ).tabs( "option", "active", selectedTab );
    //following part only if You need copyable deeplinks
    
    $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
    
        var re = /#\w+$/;
        var url = document.location.toString();
    var newHash = 'yourTabID-' + ui.newTab.context.id.substring(6);
    window.location.hash = newHash;
    } );
    }
    

相关问题