讲的很好,有个小错误,判断团购结束的时候,应该要加个清除定时器的操作吧,不然的话,即使lefttime<=0,还是会继续执行下去,而不会显示“团购结束”。
window.onload = function(){
var timedate= new Date('2016,9,1');
var now = new Date() ;
var date = timedate.getTime() - now.getTime();
var time = Math.ceil(date/(24*60*60*1000) );
if(time > 0 ){
document.getElementById('timeShow').innerHTML = time;
}
}
var timedate= new Date('2016,9,1');
var now = new Date() ;
var date = timedate.getTime() - now.getTime();
var time = Math.ceil(date/(24*60*60*1000) );
if(time > 0 ){
document.getElementById('timeShow').innerHTML = time;
}
}