关于之前和现在setTimeout问题
window.onload=function(){
FrashTime()
}
function FrashTime(){
var endtime = new Date("2016/10/7,9:54:00");
var nowtime= new Date();
var lefttime=parseInt((endtime.getTime()-nowtime.getTime())/1000);
var time =50;
var d=parseInt(lefttime/(24*60*60));
var h=parseInt(lefttime/(60*60)%24);
var m=parseInt(lefttime/60%60);
var s=parseInt(lefttime%60);
document.getElementById("LeftTime").innerHTML=d+"天"+h+"小时"+m+"分"+s+"秒"
if(lefttime<=0){
document.getElementById("LeftTime").innerHTML="团购已经结束"
}
setTimeout(FrashTime,time);
}
按照他讲的只执行一次为什么setTimeout可以在限时抢中显示计时器功能