js单纯的倒计时

<div>倒计时<span id="ant">123</span>秒</div>

window.onload = function () {
var odiv = document.getElementById("ant");
var count = 60;
odiv.innerText = count;
var timer = null;
timer = setInterval(function () {
if (count > 0) {
count = count - 1;
odiv.innerText = count;
}
else {
clearInterval(timer);
}
}, 1000);
}

百度搜到的  不是原创  简单保留一下

猜你喜欢

转载自www.cnblogs.com/yyy251/p/9118784.html