📜  将倒数计时器添加到 javascript 测验 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:01.388000             🧑  作者: Mango

代码示例1
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);