限时抢购-倒计时的完整实例(分享)
程序员文章站
2022-09-08 12:29:53
如下所示:
如下所示:
<!doctype html> <html> <head> <meta charset=utf-8"/> <title>团购——限时抢</title> </head> <body> <div> <div class="time">还剩 <span id="lefttime"></span></div> </div> <script> function freshtime() { var endtime = new date("2017/10/15,12:20:12");//结束时间 var nowtime = new date();//当前时间 var lefttime = parseint((endtime.gettime() - nowtime.gettime()) / 1000); d = parseint(lefttime / (24 * 3600)); h = parseint(lefttime /3600%24); m = parseint(lefttime/60%60); s = parseint(lefttime % 60); document.getelementbyid("lefttime").innerhtml = d + "天" + h + "小时" + m + "分" + s + "秒"; if (lefttime <= 0) { document.getelementbyid("lefttime").innerhtml = "团购已结束"; clearinterval(sh); } } var sh; sh = setinterval(function () { freshtime() },500); </script> </body> </html>
效果图:
以上这篇限时抢购-倒计时的完整实例(分享)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。