问题是jquery的动画功能是从最后一行开始的第5行,如果我删除该行它工作正常,否则它会崩溃浏览器{firefox尤其},但我需要该动画功能让用户知道新的更新。 ..任何人都可以告诉我为什么动画功能会崩溃浏览器???
function doAnimation() {
var newUpdate = newUpdates.updates[updateIterator] != null ? newUpdates.updates[updateIterator] : null;
var update = "";
while (newUpdate != null) {
if (updateIterator == 0) {
$(".nodata").hide();
}
lastupdateTime = newUpdate.lastUpdate;
update += "<div class='live-updates-data'><img width='48px' height='48px' class='" + newUpdate.clientId + "' src='company_logo/thumb/" + newUpdate.img + "' align='logo' onerror='showDefaultimage(this);' /><h2><span>" + newUpdate.title + "</span></h2> <a style='font-family:Arial, Helvetica, sans-serif' class='" + newUpdate.clientId + " mp'> | Join Chat </a><p>" + newUpdate.updateMessage + "</p></div>";
updateIterator++;
newUpdate = newUpdates.updates[updateIterator] != null ? newUpdates.updates[updateIterator] : null;
} // end of while
// after finishing the while loop
if (update != "") {
$("#shoutBox").prepend(update);
$("#shoutBox div:first-child").animate({
"height": "toggle"
}, "slow", "linear");
}
oTimeout = setTimeout(getShouts, timoutSpeed); //Again start the timout function to ge
updateIterator = 0;
return false;
}
答案 0 :(得分:0)
这将持续触发$(".nodata").hide();
,它将附加在jquery动画队列中。
把它写成......
if (updateIterator === 0 && !$(".nodata").is(":hidden")) {
$(".nodata").hide();
}