i have a setInterval() function which is used as follows
setInterval(function(){
if(window.document.drops.isFinished()){
//I want to exit the setInterval() on executing this if
}
},1000);
or tell me what is the method to exit.(In java we use System.exit(0))
i have a setInterval() function which is used as follows
setInterval(function(){
if(window.document.drops.isFinished()){
//I want to exit the setInterval() on executing this if
}
},1000);
or tell me what is the method to exit.(In java we use System.exit(0))
Share Improve this question edited Jul 6, 2013 at 18:33 nicosantangelo 13.7k3 gold badges34 silver badges47 bronze badges asked Jul 6, 2013 at 18:31 Udanesh NUdanesh N 1712 gold badges2 silver badges15 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 23 var timerId = setInterval(function(){
if(window.document.drops.isFinished()){
clearInterval(timerId);
}
},1000);
If the if
it's not the last thing in the function and you want to "break" the execution, maybe you want to also add a return;
statement after the clearInterval
.
return
. – JJJ Commented Jul 6, 2013 at 18:36