Skip to content Skip to sidebar Skip to footer

Clear Countdown Timer

I have this function that implements a countdown (MM:SS). I pass the minutes and seconds in the function and the countdown will start. Now, I'd like the countdown to reset and rest

Solution 1:

Retrieve the id of the current timer and cancel it before setting the new one.

Courtesy w3schools: -

var myVar;

function myFunction() {
    myVar = setTimeout(function(){ alert("Hello") }, 3000);
}

function myStopFunction() {
    clearTimeout(myVar);

}

Post a Comment for "Clear Countdown Timer"