Prev Demo
JavaScript
>
Stopping Timers
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Time Stopper</h1> <script> var count = 0; function TestFunction() { count++; document.getElementById("lblText").innerHTML = count; t = setTimeout("TestFunction()", 1000); } function StopCount() { clearTimeout(t); } </script> <label id="lblText">0</label> <input type="button" id="btnTest" onclick="TestFunction()" value="Start Timer" /> <input type="button" id="btnStop" value="Stop Timer" onclick="StopCount()" /> </body> </html>
Note: We DO NOT save your trial code in our database.
Output