I have a count up timer and I want to create a reset button to start from 00:00 This is my code:
<label id="minutes">00</label>
<label id="colon">:</label>
<label id="seconds">00</label>
setInterval(setTime, 1000);
function setTime(){
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds%60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds/60));
}
function pad(val){
var valString = val + "";
if(valString.length < 2)
{
return "0" + valString;
}
else
{
return valString;
}
}
// reset() function
function resertTimer(){
document.getElementById("minutes").innerHTML = "00";
document.getElementById("seconds").innerHTML = "00";
}
When I call the reset function, it changes the timer to 00:00 but then goes back to the previous value again. Like if the value was 00:15, it changes to 00:00 then goes back to 00:16