前一段時間我問這個問題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