团购、定时抢购倒计时js版

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 2 <html>
 3 <head>
 4     <title>团购、定时抢购倒计时 </title>
 5     <meta http-equiv="content-type" content="text/html; charset=gb2312" />
 6     <meta name="keywords" content="" />
 7     <meta name="description" content="" />
 8 
 9     <script language="JavaScript">
10 
11         var tms = [];
12         var day = [];
13         var hour = [];
14         var minute = [];
15         var second = [];
16         function takeCount() {
17             setTimeout("takeCount()", 1000);
18             for (var i = 0, j = tms.length; i < j; i++) {
20                 tms[i] -= 1000;
21                 //计算天、时、分、秒、
22                 var days = Math.floor(tms[i] / (1000 * 60 * 60 * 24));
23                 var hours = Math.floor(tms[i] / (1000 * 60 * 60)) % 24;
24                 var minutes = Math.floor(tms[i] / (1000 * 60)) % 60;
25                 var seconds = Math.floor(tms[i] / 1000) % 60;
26                 if (days < 0)
27                     days = 0;
28                 if (hours < 0)
29                     hours = 0;
30                 if (minutes < 0)
31                     minutes = 0;
32                 if (seconds < 0)
33                     seconds = 0;
34                 //将天、时、分、秒插入到html中
35                 document.getElementById(day[i]).innerHTML = days;
36                 document.getElementById(hour[i]).innerHTML = hours;
37                 document.getElementById(minute[i]).innerHTML = minutes;
38                 document.getElementById(second[i]).innerHTML = seconds;
39             }
40         }
41         setTimeout("takeCount()", 1000);
42     </script>
43 
44 </head>
45 <body>
46     <div>
47         <ul>
48             <li style="width: 300px;">剩余时间: <span id="d1" style="font-weight: bold">0</span> <span>
49                 天 </span><span id="h1" style="font-weight: bold">0</span> <span>小时 </span><span id="m1"
50                     style="font-weight: bold">0</span> <span>分 </span><span id="s1" style="font-weight: bold">
51                         0</span> <span>秒</span></li>
52 
53             <script type="text/javascript">
54                 tms[tms.length] = "168935343345";
55                 day[day.length] = "d1";
56                 hour[hour.length] = "h1";
57                 minute[minute.length] = "m1";
58                 second[second.length] = "s1";
59             </script>
60 
61             <li style="width: 300px;">剩余时间: <span id="d2" style="font-weight: bold">0</span> <span>
62                 天 </span><span id="h2" style="font-weight: bold">0</span> <span>小时 </span><span id="m2"
63                     style="font-weight: bold">0</span> <span>分 </span><span id="s2" style="font-weight: bold">
64                         0</span> <span>秒</span></li>
65 
66             <script type="text/javascript">
67                 tms[tms.length] = "1689353433455";
68                 day[day.length] = "d2";
69                 hour[hour.length] = "h2";
70                 minute[minute.length] = "m2";
71                 second[second.length] = "s2";
72             </script>
73 
74         </ul>
75     </div>
76 </body>
77 </html>
78 


完整代码点击团购、定时抢购倒计时js版

转:http://www.cnblogs.com/xiaohai511/archive/2010/08/02/1790303.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值