js实现10秒倒计时跳转,一般用setTimeout或者setInterval,还有其它的函数来实现吗
js实现10秒倒计时跳转,一般用setTimeout或者setInterval,还有其它的函数来实现吗
function showTime(count) {
document.getElementById('showtimes').innerHTML = count;
if (count == 0) {
// do job
} else {
count -= 1;
setTimeout(function () {
showTime(count);
}, 1000);
}
}
一般这样写就行了。