+ 1

How to use clearInterval?

12th Jul 2017, 5:03 PM
Ankush Singh
Ankush Singh - avatar
2 Respuestas
+ 4
When you create your setinterval, make sure that you assign it to a variable so you can stop it later, especially if you have more than one running. Example: var helloInterval = setInterval(function(){ alert("Hello"); }, 3000); To stop: clearInterval(helloInterval); Hope that helps.
12th Jul 2017, 5:40 PM
AgentSmith
+ 2
clearInterval() will basically stop the setInterval() function you give it from running. More info here: https://www.w3schools.com/jsref/met_win_clearinterval.asp
12th Jul 2017, 5:16 PM
Rrestoring faith
Rrestoring faith - avatar