I tried implementing this clock into a polling app of sorts, problem is that whenever the host clicks a button sending the participants to a new question and starting a new clock, the old ones is still active and the webpage ends up jumping between the two eg 2->41->3->42.
How do I abort this clock with the help of a button press?
var sec = 0;
function pad(val) {
return val > 9 ? val : "0" + val;
}
setInterval(function() {
document.getElementById("seconds").innerHTML = pad(++sec);
}, 1000);
<div class="clock">
<span id="seconds"></span>
</div>