Skip to content
Advertisement

Can’t stop setInterval with clearInterval

Been playing with this in a fiddle for 4 hours now and cant find a solution…

HTML:

JavaScript

js:

JavaScript

Note: because clearInterval is not working you need to click on “run” in the jsfiddle to get it to stop after clicking the checkbox, you have 7 seconds between alerts…

Here is a link to the jsfiddle: http://jsfiddle.net/5udtC/5966/

Thanks!

Advertisement

Answer

Don’t redefine the variable in the local scope

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement