JS-倒计时效果

团购-限时抢

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>团购——限时抢</title>
 6 <link rel="stylesheet" href="style.css"  />
 7 </head>
 8 
 9 <body>
10 <div class="content3">
11 <div class="time">还剩 <span id="LeftTime"></span></div>
12 </div>
13 <script>
14 function FreshTime()
15 {
16         var endtime=new Date("2017/5/15,12:20:12");//结束时间
17         var nowtime = new Date();//当前时间
18         var lefttime=parseInt((endtime.getTime()-nowtime.getTime())/1000); 
19         d=parseInt(lefttime/3600/24);
20         h=parseInt((lefttime/3600)%24);
21         m=parseInt((lefttime/60)%60);
22         s=parseInt(lefttime%60);
23        
24         document.getElementById("LeftTime").innerHTML=d+""+h+"小时"+m+""+s+"";
25         if(lefttime<=0){
26         document.getElementById("LeftTime").innerHTML="团购已结束";
27         clearInterval(sh);
28         }
29 }
30 FreshTime()
31 var sh;
32 sh=setInterval(FreshTime,1000);
33 </script>
34 </body>
35 </html>

 

上一篇:美*采用云计算面临问题多


下一篇:响应式滑块动画插件