Skip to content
Sign upLog in

How do i make a countdown timer?

Profile icon

I need help with making a countdown timer and notification system when it goes off, could anyone help? comment pls if you can!

You are viewing a single comment. View All
Answered by Whacko [earned 5 cycles]
View Answer
Profile icon

Oops... I used value instead of innerHTML.
Here's the working code:

<p id="countdown">60</p> <script> var timer = 60 /* Change it to whatever you want */ var timerText = document.getElementById("countdown"); var countdown = setInterval(function() { if (timer == 0) { clearInterval(); /* End */ timerText.innerHTML = "Out of time!"; } else { timer -= 1 /* Countdown */ timerText.innerHTML = timer; }; }, 1000 /* Miloseconds */); </script>

Now it should work.