My
setInterval('name(var)',6000);
won't clear with:
clearInterval('name(var)');
or with:
clearInterval('name(var)');
why?
setInterval returns a handle of the interval, so you do it like this:
var myInterval = setInterval(function(){ name(var) }, 6000);
clearInterval(myInterval);
Note: Notice how I used a anonymous function instead of a string too.
You need to store the returned intervalID and pass it to clearInterval later.
var intervalID = setInterval('name(var)',6000);
clearInterval(intervalID);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With