尝试使用jquery在我的网站的portfolio部分使用选项卡式界面。
我需要做的就是在用户单击该选项卡的链接时,将“active”类添加到li元素中。我认为我的代码是相当典型的,虽然只能在google chrome和safari中工作。火狐和internet explorer会在第一个li中添加'active‘类,在点击另一个标签时将其移除,但不会将'active’添加到所点击的标签中。
代码:
$(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();
}); 发布于 2010-07-10 01:12:26
要让FF正常工作,您只需在function()中添加"event“,如下所示:
$('#tabbed-interface>ul>li>a').click(function(event){发布于 2010-07-10 01:13:58
也许可以考虑更改这一行:
$(event.target).parent().addClass('active');成为
$(this).parent().addClass('active');https://stackoverflow.com/questions/3214892
复制相似问题