jquery网页倒计时效果,秒杀

function FreshTime(){
var endtime=new Date('2019-4-12 18:00:00');//结束时间
var nowtime = new Date();//当前时间
var lefttime=parseInt((endtime.getTime()-nowtime.getTime())/1000);
d=parseInt(lefttime/3600/24);
h=parseInt((lefttime/3600)%24);
m=parseInt((lefttime/60)%60);
s=parseInt(lefttime%60); document.getElementById("Time").innerHTML="还剩" + d+"天"+h+"小时"+m+"分"+s+"秒";
if(lefttime<=0){
document.getElementById("Time").innerHTML="秒杀已结束";
clearInterval(hh);
$(".operate_btn").show()
}
}
FreshTime();
var hh;
hh=setInterval(FreshTime,1000);

效果如下:

jquery网页倒计时效果,秒杀

上一篇:jquery网页倒计时效果,秒杀,限时抢购!


下一篇:ios - block循环引用Demo示例