stop countdown timer
Hi, I'm using this code below, and it's working perfectly fine. So, when I click a button, I'm running the HTML. However, when I click on the popup and close it, the timer is still running. How can I stop it once i exit the popup.
function startTimer(duration, display) {
var start = Date.now(),
diff,
minutes,
seconds;
function timer() {
// get the number of seconds that have elapsed since
// startTimer() was called
diff = duration - (((Date.now() - start) / 1000) | 0);
Code: Select all
// does the same job as parseInt truncates the float
minutes = (diff / 60) | 0;
seconds = (diff % 60) | 0;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + ":" + seconds;
if (diff
Registration closes in span/span minutes!