很正常啊。。
var num = document.getElementById("time").innerHTML
setInterval(function () {
if(num > 1){
document.getElementById('time').innerHTML = --num;
}else{
location.assign('http://www.imooc.com')
}
},1000)
试试看
或者用timeout
var num = document.getElementById("time").innerHTML
setTimeout(go,1000)
function go(){
if(num > 1){
document.getElementById('time').innerHTML = --num;
setTimeout(go,1000)
}else{
location.assign('http://www.imooc.com')
}
} |