Timer Display
Hi,
I am trying to build a timer that counts down from 60 to 0, and displays the countdown on the page. Upon success of a particular service, I trigger the JS for this timer. I have the following code, which I believe should be working. However, I get an error saying that the secondPassed function is not defined. Do you know what the problem may be?
var seconds = 60;
function secondPassed() {
document.getElementById(‘test_countdown').innerHTML = seconds;
if (seconds == 0) {
clearInterval(countdownTimer);
document.getElementById(‘test_countdown').innerHTML = "Buzz Buzz";
}
else {
seconds--;
}
}
var countdownTimer = setInterval('secondPassed()', 1000);
Here is an image also for your reference:
I don't know why the error / warning signs show up next to the JS. When I first write the code, the signs don't show up. But when I hit "edit event" and then go back to view the code, they show up.
Thank you for your help!