团购、定时抢购倒计时js版 时间:2020-05-12 人气:0 团购、定时抢购倒计时 <script language="JavaScript"> var tms = []; var day = []; var hour = []; var minute = []; var second = []; function takeCount() { setTimeout("takeCount()", 1000); for (var i = 0, j = tms.length; i < j; i++) { //计数减一 tms[i] -= 1000; //计算时分秒 var days = Math.floor(tms[i] / (1000 * 60 * 60 * 24)); var hours = Math.floor(tms[i] / (1000 * 60 * 60)) % 24; var minutes = Math.floor(tms[i] / (1000 * 60)) % 60; var seconds = Math.floor(tms[i] / 1000) % 60; if (days < 0) days = 0; if (hours < 0) hours = 0; if (minutes < 0) minutes = 0; if (seconds < 0) seconds = 0; //将时分秒插入到html中 document.getElementById(day[i]).innerHTML = days; document.getElementById(hour[i]).innerHTML = hours; document.getElementById(minute[i]).innerHTML = minutes; document.getElementById(second[i]).innerHTML = seconds; } } setTimeout("takeCount()", 1000); </script> 剩余时间: 0 天 0 小时 0 分 0 秒 <script type="text/javascript"> tms[tms.length] = "168935343345"; day[day.length] = "d1"; hour[hour.length] = "h1"; minute[minute.length] = "m1"; second[second.length] = "s1"; </script> 剩余时间: 0 天 0 小时 0 分 0 秒 <script type="text/javascript"> tms[tms.length] = "1689353433455"; day[day.length] = "d2"; hour[hour.length] = "h2"; minute[minute.length] = "m2"; second[second.length] = "s2"; </script> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容