0

我在 Internet Explorer 8 中遇到了 jQuery setInterval 函数的问题。我有一个脚本可以阻止动画被触发,直到上一个动画完成。它在 Chrome、Firefox 和 IE 9 中也能正常工作,但在 IE 8 中第二个动画无法启动。我也确信问题出在间隔上,因为没有它,工作正常。请参阅下面的代码:

 $('#name').animate({top: "325"}, 2000);
 $('#line').animate({width: "525"}, 2000);
 var wait = setInterval(function() {
    if( !$("#line, #name").is(":animated") ) {
       clearInterval(wait);
       $('#photo').fadeIn(2500);
       $('#enter').show(3000);
    }
 }, 0);

任何帮助表示赞赏!

4

1 回答 1

1

我建议对 .animate 方法使用回调

function showItems () {
   $('#photo').fadeIn(2500);
   $('#enter').show(3000);
}
$('#line').animate({width: "525"}, 2000, showItems);

似乎问题不在于 .animate() 方法和动画。在 IE8 中,我根本看不到“Enter”链接。所以它与你的标记有关。尝试制作一个有效的 XHTML。

于 2012-04-07T15:11:07.303 回答