js 倒计时

时间:2014-05-08 11:25:28   收藏:0   阅读:654
   <script>
                 function daoJiShi(endDate)
                    {   
                     var now=new Date().getTime()/1000;  ;
                     var oft=Math.round((endDate-now));
                     var ofd=parseInt(oft/3600/24);
                     var ofh=parseInt((oft%(3600*24))/3600);
                     var ofm=parseInt((oft%3600)/60);
                     var ofs=oft%60;
                     document.getElementById(‘end_date_0_class‘).innerHTML=‘还有 ‘+ofd+‘ 天 ‘ +ofh+ ‘ 小时 ‘ +ofm+ ‘ 分钟 ‘ +ofs+ ‘ 秒‘;
                     if(ofs<0){document.getElementById(‘end_date_0_class‘).innerHTML=‘倒计时结束!‘;return;};
                     setTimeout("daoJiShi("+endDate+")",1000);
                    };

           </script>

js 倒计时,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!