How to pause and resume a javascript timer [duplicate]
I have this timer which works fine, but i need to be able to pause and resume it after that. i would appreciate it if someone could help me. <html> <head> <script> function startTimer(m,s) { document.getElementById('timer').innerHTML= m+":"+s; if (s==0) { if (m == 0) { return; } else if (m != 0) { m = m-1; s = 60; } } s = s-1; t=setTimeout(function(){startTimer(m,s)},1000); } </script> </head> <body> <button onClick = "startTimer(5,0)">Start</button> <p id = "timer">00:00</p> </body> </html>
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.