juqery 实现商城循环倒计时

 1 <html>
 2 <hand>
 3 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
 4 </script>
 5 </hand>
 6 <body>
 7 
 8 <!-- 本代码没有加入juqery,请在使用前你手动加入juqery库 -->
 9 <span class="showtime" nowtime="2100/03/20 00:00:00"> d</span>
10 <span class="showtime" nowtime="2100/03/10 00:00:00" > w </span>
11 <script>
12 $(".showtime").click(function(){
13     alert(2);
14 })
15 /*时间倒计时 star    */
16 $(".showtime").click(function(){
17    var _this = $(this);
18    var nowtime = _this.attr('nowtime');
19    var EndTime= new Date(nowtime);
20    var NowTime = new Date();
21    var t =EndTime.getTime() - NowTime.getTime();
22    var d=Math.floor(t/1000/60/60/24);
23    var h=Math.floor(t/1000/60/60%24);
24    var m=Math.floor(t/1000/60%60);
25    var s=Math.floor(t/1000%60);
26    var timestr = '还剩'+d + '天' + h + '时' + m + '分' + s + '秒';
27 
28     _this.html(timestr);
29 });
30 function doRtime(){
31     $(".showtime").trigger("click");
32 }
33 
34 setInterval(doRtime,0);
35 /*时间倒计时 end    */
36 </script>
37 
38 </body>
39 </html>

 

posted @ 2016-03-15 13:38  Abner3721  阅读(193)  评论(0编辑  收藏  举报