首页 > 代码库 > 倒计时代码
倒计时代码
<script language="javascript" type="text/javascript"> var interval = 1000; function toDb(n){ if(n<10){ return ‘0‘+n; } else { return ‘‘+n; } }; function ShowCountDown(year,month,day,divname) { var now = new Date(); var endDate = new Date(year, month-1, day); var leftTime=endDate.getTime()-now.getTime(); var leftsecond = parseInt(leftTime/1000); var day1=toDb(Math.floor(leftsecond/(60*60*24))); var hour=toDb(Math.floor((leftsecond-day1*24*60*60)/3600)); var minute=toDb(Math.floor((leftsecond-day1*24*60*60-hour*3600)/60)); var second=toDb(Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60)); var cc = document.getElementById(divname); cc.innerHTML = "距离活动结束,仅剩下 <span class=‘red‘>"+day1+"</span>天 <span class=‘red‘>"+hour+"</span>时 <span class=‘red‘>"+minute+"</span>分 <span class=‘red‘>"+second+"</span>秒"; }; window.setInterval(function(){ShowCountDown(2016,10,15,‘lastTime‘);}, interval); </script>
倒计时代码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。