$(document).ready(function() {
var url = document.location.toString();
$('.tab').click(function() {
if($(this).is(".active")) {
return;
}
var classy = $(this).attr("class").split(" ").splice(-1);
var innerhtml = $('.content.'+classy).text();
$('#holder').html(innerhtml);
$('.tab').removeClass('active');
$(this).addClass('active');
});
var url = document.location.toString();
if(url.match(/#([a-z])/)) {
//There is a hash, followed by letters in it, therefore the user is targetting a page.
var split = url.split("#").splice(-1);
$('.tab.'+split).click();
}
else {
$('.tab:first').click();
}
});
嘿,我刚刚被我的一位评论者告知,这段代码在IE中不起作用。我不能为了我的生活找出原因。无论何时切换标签,标签的内容都不会改变。同时#holder div的内容是所有标签组合的。代码与IE不兼容?
任何想法?
他们说了,他们使用这些版本的IE? IE6充斥着大多在IE7/8中修复的问题。 – Powerlord 2009-08-25 18:53:12
我不知道答案,但我会先在IE8中尝试它。如果它在那里工作,然后按F12开启开发者控制台,然后点击地址栏旁边的损坏的页面图标进入IE6/7兼容模式。这将重新加载页面,并且您的代码导致的任何错误都将显示在开发者控制台中。 如果它仍然有效,那么只有这样你才能找到一个真正的IE6机器。 – 2009-08-25 18:54:27
嘿,这仍然不起作用。代码链接在下面的评论中。任何帮助深表感谢。 – Johnny 2009-08-25 19:07:32