2012-11-14 38 views
0

我正在使用此解決方案以具有multiple tabs in one page放置在底部的jQuery選項卡控件不起作用

$(".tab_content").not(':first-child').hide(); 
var tabs = $('.tabs li'); 

tabs.filter(':first-child').addClass('active'); 

tabs.click(function() { 
    var current = $(this); 

    if(!current.hasClass('active')){ 
     current.addClass('active').siblings().removeClass('active'); 
     var activeTab = current.find("a").attr("href"); 
     current.parent().next().children().hide().filter(activeTab).fadeIn(); 
    } 

    return false; 
}); 

我需要在選項卡內容後放置選項卡控件。 但它不會工作。如果選項卡控件放在選項卡內容之前,它可以正常工作。 你能幫我嗎?

這裏是我的jsfiddle

+0

你有相同的多個元素ID。這是一個沒有沒有, – lbstr

回答

1

只是改變未來()來prev() - 因爲現在的兄弟姐妹是以前的標籤

current.parent().prev().children().hide().filter(activeTab).fadeIn(); 

http://jsfiddle.net/Kf2f4/

+0

;-)就這麼簡單..非常感謝,我真的很感激。今天學到很好的東西。 – Grashopper