代码如下
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); }