Get named function for continuous repeat in jQuery

I am trying to get a function to repeat it as soon as it starts, but I have to be today because I cannot figure it out. Here is my code:

function runNext() {
    galleryNext().delay(1500).runNext();
}

Thanks in advance.

+5
source share
2 answers

If you want to call a function at a regular interval, you should use setInterval().

var myFunction = function() {};
setInterval(myFunction, 1000); // call every 1000 milliseconds

If you ever need to stop a function from being called forever, setInterval () returns an identifier that you can also use to stop the timer. Here is an example.

var myFunction = function() {};
var timer = setInterval(myFunction, 1000);
clearTimeout(timer);
+16
source

, , DOM. jQuery DOM- , DOM node. delay , , , - , setTimeout:

(function foo() {
  setTimeout(function() { foo() },1000);
  })();
+2

All Articles