2013-08-21 126 views
0

如何获取一个jquery动画每5秒运行一次?每5秒运行一次jquery动画

所以这样的东西。

$('.zoom_big').animate({opacity: 1},2000,functions()}{ 
      $('.zoom_big').animate({opacity: 0},2000); 
}); 
+5

http://stackoverflow.com/questions/3549853/jquery-how-to-每5秒发射一次相同的事件 –

+0

http://stackoverflow.com/questions/1301529/jquery-fade-with-loop-and-delay –

回答

3

您可以使用javascript's setInterval()

var t = setInterval(function(){ // run the following function 

    $('.zoom_big').animate({opacity: 1},2000,functions()}{ 
      $('.zoom_big').animate({opacity: 0},2000); 
    }); 

},5000); // every 5000 milliseconds = 5 seconds 

要停止它,你可以使用clearInterval()

clearInterval(t);