在尋找解決方案似乎很長時間後,我認爲是時候問問專家。HTML鏈接觸發某些jQuery選項卡
我已經在我的網站上實現了jQuery選項卡,但是還要選擇一個選項卡來顯示內容,如果您單擊頁面上其他標準html鏈接,我也希望能夠顯示不同的選項卡內容。
頁面可以在這裏看到http://www.luxury-spa-breaks.com/spa-deals-TEST.html和問題的html鏈接是左手邊的那些(例如,用戶可以選擇他們想要的標籤,或者從左邊選擇一個區域,然後顯示那個區域標籤內容)。
這是JS我目前有:
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").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 href attribute value to identify the active tab + content
$(activeTab).fadeIn(2000); //Fade in the active ID content
return false;
});
});
你的幫助是大規模感謝!
安迪
嗨Yi Jang, 感謝上述......我完全按照上面的方法複製了代碼,以取代已存在的jquery標籤代碼,它從來沒有工作過。 每個選項卡式內容區域都列在另一個下面,而不是在點擊之前隱藏。 任何想法我做錯了什麼? 再次感謝! – Motley9735 2010-11-14 12:43:09
@user您是否將它包含在'document.ready'事件處理程序中? – 2010-11-14 12:58:26
@user此外,側邊欄上除前兩個「東南」和「南西」之外的所有鏈接都有有效的工作所需的「href」值 - 您是否也檢查過? – 2010-11-14 17:29:05