2010-07-09 54 views
1

試圖在我的網站的投資組合部分使用jquery使用選項卡式界面。jquery - ff中的選項卡式界面問題,例如

我需要的所有東西都是當用戶單擊該選項卡的鏈接時,將類'活動'添加到li元素。我認爲我的代碼很典型,但只能在谷歌瀏覽器和Safari瀏覽器中運行。 firefox和IE瀏覽器會向第一個li添加「活動」類,在點擊另一個標籤時移除它,但不會將「活動」添加到單擊的選項卡中。

代碼:

$(document).ready(function(){       
    $('#tabbed-interface li:first').addClass('active'); 
    $('#tabbed-interface>ul>li>a').click(function(){ 
     $('#tabbed-interface>ul>li').removeClass('active'); 
     $(event.target).parent().addClass('active'); 
     $('#tabbed-interface>div').fadeOut(250).filter(this.hash).fadeIn(250); 
     return false; 
    }); 
    $('#tabbed-interface>div').css('position','absolute').not(':first').hide(); 
}); 

回答

1

爲FF到作品中,你只需要像添加 「事件」 內部函數():

$('#tabbed-interface>ul>li>a').click(function(event){ 
1

也許考慮改變這一行:

$(event.target).parent().addClass('active'); 

$(this).parent().addClass('active');