我試圖讓引導程序在頁面加載時跳轉到特定選項卡。儘管我在這裏找到了很少的答案,但在我的具體情況中,我嵌套了使事情複雜化的標籤。現在我已經實施瞭解決方案,如https://stackoverflow.com/a/15060168/1829478,但是我仍然無法正常工作。他提到「兒童應該有班級=」嵌套「,這是什麼意思?Twitter引導轉到嵌套選項卡的特定選項卡
function handleTabLinks() {
if(window.location.hash == '') {
window.location.hash = window.location.hash + '#_';
}
var hash = window.location.hash.split('#')[1];
var prefix = '_';
var hpieces = hash.split('/');
for (var i=0;i<hpieces.length;i++) {
var domelid = hpieces[i].replace(prefix,'');
var domitem = $('a[href=#' + domelid + '][data-toggle=tab]');
if (domitem.length > 0) {
domitem.tab('show');
}
}
$('a[data-toggle=tab]').on('shown', function (e) {
if ($(this).hasClass('nested')) {
var nested = window.location.hash.split('/');
window.location.hash = nested[0] + '/' + e.target.hash.split('#')[1];
} else {
window.location.hash = e.target.hash.replace('#', '#' + prefix);
}
});
}
添加類=「嵌套」您的嵌套的標籤的鏈接。顯示你的html和鏈接。你在哪裏以及如何調用'handleTabLinks'? –