JS实现30s倒计时

代码如下

var timestart = 30;
var timestep = -1;
var timeID;
function timecount() {
    document.getElementById("timeout").innerHTML = timestart;
    timestart += timestep;
    if(timestart < 0){
      timestart = 30;
      //倒计时为0时执行xxxx方法   
    }
    timeID=setTimeout("timecount()",1000);
}
posted @ 2020-01-06 17:33  xiaomogugu  阅读(2978)  评论(0编辑  收藏  举报