Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the first button to alert "Hello" after waiting 3 seconds.</p> <p>Click the second button to prevent the first function to execute. (You must click it before the 3 seconds are up.)</p> <button onclick="myFunction()">Try it</button> <button onclick="myStopFunction()">Stop the alert</button> <script> var myVar; function myFunction() { myVar = setTimeout(function(){ alert("Hello"); }, 3000); } function myStopFunction() { clearTimeout(myVar); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_cleartimeout by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:27:56 GMT --> </html>
Result:
Try it Yourself - © w3schools.com