下面的一段jQuery用在顶部有消息的页面上,以及所有回复下面消息的注释。代码在IE8/Chrome/Firefox上的工作方式是“折叠”初始消息下面的所有评论,所以只显示他们的主题。点击他们的主题,然后用最初的消息替代评论(即它“伪装”每个评论在自己的页面上的行为)。IE6不喜欢我简单的jQuery:任何想法为什么?
问题是IE6拒绝使用代码;当IE6访问者登录页面时,所有评论拒绝崩溃,并且点击标题无效。
有没有人有任何想法如何纠正这个问题,使JS IE6兼容?
function flip(comment) {
$('#first-post').replaceWith(comment.closest(".comment").clone().attr('id','first-post'));
$('#first-post').children('.forumthreadtitle').children('.comment-info').empty();
$('#first-post').find(':hidden').fadeIn('slow');
$('html, body').animate({scrollTop:0}, 'fast');
return false;
}
$(document).ready(
function(){
$('.submitted').each(function() {
$(this).clone().addClass('comment-info').appendTo($(this).siblings('.forumthreadtitle'));
if(!$(this).parent('#first-post').html()) {
$('#first-post').children('span.taxonomy').clone().appendTo($(this));
}
});
$('.display_mode').html('Show All Replies');
expandedMode = false;
$('.display_mode').click(function() {
if (expandedMode == false ) {
$('.forumthreadtitle').siblings().show();
$(this).html('Collapse Replies');
expandedMode = true;
}
else
{
$('.forumthreadtitle').siblings().hide();
$(this).html('Show All Replies');
expandedMode = false;
}
});
$('.forumthreadtitle').siblings().hide();
if(window.location.hash) {
flip($(window.location.hash).next().children('.forumthreadtitle').show());
}
$('.forumthreadtitle').click(function() {
pageTracker._trackPageview("/comment?page=" + document.location.pathname);
flip($(this));
});
});
下面是一些例子HTML(试图简化它一点点,使其更容易理解):
<DIV id="first-post">
<H2 class="title"><A href="test.html">TEST</A></H2>
<SPAN class="submitted">Submitted by Big J on July 26, 2010 - 3:26pm</SPAN>
<DIV class="content">First Post</DIV>
</DIV>
<DIV id="comments">
<A id="comment-1643951"></A>
<DIV class="comment comment-published clear-block">
<H3 class="forumthreadtitle"><A href="test.html#comment-1643951" class="active">Test Reply....</A>
<DIV class="submitted comment-info">Submitted by test on July 26, 2010 - 4:49pm.</DIV>
</H3>
<DIV class="content" style="display: none; ">
Test Comment Content
</DIV>
</DIV>
</DIV>
你有没有试过看这里:http://stackoverflow.com/questions/463800/jquery-document-ready-failing-in-ie6? – nandokakimoto 2010-07-27 00:38:25
我有 - 我没有任何运气改变$(文档)jQuery - 谢谢你的建议 – 2010-07-27 02:42:36