Prev Demo
Stopping The Current Run Time In Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <p>Stopping the current run time.</p> <input type="button" value="Stop" onclick="myFunction()"/> <p id="myId"></p> <script> var myTime = setInterval(function () { myStoptime() }, 1000); function myStoptime() { var a = new Date(); var b = a.toLocaleTimeString(); document.getElementById("myId").innerHTML = b; } function myFunction() { clearInterval(myTime); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output