javascript create a second countdown timer code example
Example 1: add countdown timer to javascript quiz
var count = 15;
var interval = setInterval(function(){
document.getElementById('count').innerHTML=count;
count--;
if (count === 0){
clearInterval(interval);
document.getElementById('count').innerHTML='Done';
// or...
alert("You're out of time!");
}
}, 1000);
Example 2: javascript countdown 10 seconds
var timeleft = 10;
var downloadTimer = setInterval(function(){
if(timeleft <= 0){
clearInterval(downloadTimer);
}
document.getElementById("progressBar").value = 10 - timeleft;
timeleft -= 1;
}, 1000);
<progress value="0" max="10" id="progressBar"></progress>
Example 3: countdown in js
<body>
<div>Registration closes in <span id="time">05:00</span> minutes!</div>
</body>