My timer is not working. Here is the code.
var minutesLabel = document.getElementsByClassName('lol')[0].innerText;
var secondsLabel = document.getElementsByClassName('lol1')[0].innerText;
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;
}
}
<label class="lol" id="minutes">00</label>:<label class="lol1" id="seconds">00</label>
I have been trying to call it using the class name but i don't get it why it's not working