0
這是我的選項卡。我想要在頁面重新加載時打開第二個選項卡。我怎樣才能做到這一點如何創建標籤網址
HTML
<li role="presentation" class="active">
<a href="#details" aria-controls="details" role="tab" data-toggle="tab">Details</a>
</li>
<li role="presentation">
<a href="#comments" aria-controls="comments" role="tab" data-toggle="tab">Comments: (<?php echo $comments_count[0]->total?>)</a>
</li>
我發現這個jQuery代碼,但它不工作:
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
我用這個網址進行重新加載。它轉到消息選項卡,但頁面不重新加載。 'success:function(data){ \t window.location.href =「http:// localhost/demo/item-details /?id = 19#messages」;' }, – james