0

How can a get a jquery animation to run say every 5 seconds?

so for something like this.

$('.zoom_big').animate({opacity: 1},2000,functions()}{
          $('.zoom_big').animate({opacity: 0},2000);
 });
Wanting to learn
  • 468
  • 1
  • 7
  • 25

1 Answers1

4

You can use 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

To stop it you can use clearInterval()

clearInterval(t);
Yotam Omer
  • 15,310
  • 11
  • 62
  • 65