倒计时

用js实现倒计时效果 :

html:

1 <body>
2     <div id="con">
3         
4     </div>
5 </body>

javasript:

 1 <script>
 2     window.onload=function(){
 3                     
 4        function fn_a(){
 5             
 6             var ocon=document.getElementById('con');
 7             var date=new Date();
 8             var date_a=new Date("2016/6/6,08:00:00");
 9             var time=parseInt((date_a.getTime()-date.getTime())/1000);
10             var day=parseInt(time/(24*60*60));
11             var hours=parseInt((time/3600)%24);
12             
13             var minute=parseInt((time/60)%60);
14             var second=parseInt(time%60);
15             ocon.innerHTML='距离2016/6/6,08:00:00剩余时间:</br>'+day+'天'+hours+'小时'+minute+'分钟'+second+'秒';
16                          }
17             setInterval(fn_a,30);
18 }
19 </script>
20     

 

posted @ 2016-04-08 14:46  xue11hua  阅读(181)  评论(0编辑  收藏  举报