我正在使用jquery將內容加載到標籤,並點擊切換標籤。我的問題是,我使用這個「標籤切換器」兩次,其中一個頁面,這是導致衝突。我對jQuery不太熟悉,所以我的問題可能在於我在頭部創建了兩次函數。這裏是我的jQuery(你會發現有重複的腳本,與選擇改變了一點,因此「選項卡切換」出現不同。與相同的腳本jQuery的衝突
<script type="text/javascript">
$(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(); //Fade in the active ID content
return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
//When page loads...
$(".tabs_content").hide(); //Hide all content
$("ul.tab li:first").addClass("active").show(); //Activate first tab
$(".tabs_content:first").show(); //Show first tab content
//On Click Event
$("ul.tab li").click(function() {
$("ul.tab li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tabs_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(); //Fade in the active ID content
return false;
});
});
</script>
我的CSS是正確的,我知道問題出在上面。第二個腳本工作正常,第一個腳本沒有。
你可以在這裏看到這裏:link你會注意到第二個腳本可以正常工作(在底部:margie和todd,而第一個腳本沒有' t工作(在邊欄中:類別和檔案)。
任何想法如何解決這個問題?
第一個腳本工作之前,我添加第二個,所以加入了類似的腳本就引起了休息 – JCHASE11 2010-09-11 03:21:38