2010-04-28 75 views
0
$(document).ready(function() { 

//Default Action 
$(".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 rel attribute value to identify the active tab + content 
    $(activeTab).fadeIn("slow"); //Fade in the active content 
    return false; 
}); 

}); 

工作在一切,但IE浏览器?jQuery fadeIn()在IE中不工作

+0

而不是返回false你应该使用preventDefault() – Samuel 2010-04-28 22:13:39

+0

嗯。我不希望任何涉及alpha混合的东西在IE中正常工作,但也许这仅仅是因为它支持PNG的程度有多严重...... – SamB 2010-04-28 22:15:15

回答

1

你可以做到这一点得到一致的行为:

var activeTab = $(this).find("a").get(0).hash; 

IE喜欢返回不"#id",而是它认为你想:"http://site.com/currentPage.html#id",这将不是一个选择工作:)我给你抢.hash关闭DOM元素,你只会得到他一致的部分。

You can find a bit more discussion on why this happens in this question

+0

啊,你是说它喜欢马上解析相对URI? – SamB 2010-04-28 23:30:15

0

$(this).find("a").attr("href")让你的目标,而不是目标的HREF。假设你将DIV的名称放在href中,那可能是正确的(我不知道里面是什么)。

尝试alert($(this).find("a").href())以查看您是否拥有正确的元素,或只是尝试.show()并查看会发生什么情况。