前一段时间我问这个问题Jquery tabs keep tab open that is subid in url,你可以看到我发现了一个答案我的问题,现在我试图改变它,以便每次你从标签更改选项卡它改变tid subid在头文件中,此时它只是将变量tid更改为tab_id所在的位置,以便当您按下后,可以打开您离开的特定选项卡,但这次我希望它将标头中的tid更新为您滚动选项卡。更新subid通过标签
在情况下,链接到我以前的答案并不在这里显示是我的代码
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
$(document).ready(function() {
$(".tab_content").hide(); //Hide all content
var tabIndex = parseInt(getParameterByName('tid'), 10);
if (!tabIndex) tabIndex = 1;
$("ul.tabs li").eq(tabIndex - 1).addClass("active").show(); //Activate first tab
$(".tab_content").eq(tabIndex - 1).show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});
让我知道,如果你有什么事和遗憾,如果这是一个有点混乱。
编辑:?在此刻换句话说,如果我的头添加TID = 2,那么它会去第二个选项卡,但是当您更改标签
谁能帮助我? – Arken
你能证明这一点吗?有链接? “我试图改变它,以便每次你从标签页到标签页改变它改变标题中的tid子标题” - 什么tid subid?什么标题?你是什么意思“在标题”?你在谈论改变浏览器的网址吗? –
嗨,是的tid是每个标签的“tab_id”,所以如果你把URL tid = 2,那么它会到第二个标签。而对于标题抱歉,是的,我的意思是网址 – Arken