2013-03-12 59 views
3

如何在ie7中使jquery连续循环动画& 8? (IE9 /铬正常工作)在ie7中重复执行动画

这里是我的代码

$(document).ready(function() { 
     var $grower = $('#rain'); 

     function runIt() { 
      $grower.animate({left:'48%',top:'800px',opacity:'0'}, 1000, function() { 
       $grower.removeAttr("style"); 

       setTimeout(function() { 
        runIt(); 
       }, 100); 
      }); 
     } 

     runIt(); 
    }); 
+0

它在IE7/8次工作,有没有抛出的所有的错误? – Popnoodles 2013-03-12 11:10:12

+0

try $ grower.css({opacity:1,left:'auto',top:'auto'});而不是removeAttr('style') – 2013-03-12 11:15:50

回答

0

我在IE 8尝试这样做,这是为我工作http://jsfiddle.net/8EtKy/2/

看看。

HTML

<div id="rain"></div> 

jQuery的

$(document).ready(function() { 
     var $grower = $('#rain'); 
     function runIt() { 
      $grower.animate({left:'48%',top:'800px',opacity:'0'}, 1000, function() { 
       $grower.removeAttr("style"); 

      }); 
     } 
      setInterval(runIt,100); 
    }); 

CSS

#rain{ 
    width:50px; 
    height:50px; 
    background-color:#000; 
}