html 代码 <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"/> <title>倒计时效果</title> <style type="text/css"> #countDown{font-size:48px;line-height:10;text-align:center;} </style> </head> <body> <div id="countDowntime"></div> </body> </html> <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.0/jquery.min.js"></script> <script type="text/javascript"> function countDown(){ var timeLeft=86444; var int = window.setInterval(function () { if (timeLeft > 0) { $(".countdown").removeClass('none'); timeLeft -= 1; var day = Math.floor(timeLeft /86400), hour = Math.floor((timeLeft %86400)/3600), minute = Math.floor((timeLeft % 3600) / 60), second = (timeLeft % 3600) % 60; var strtime = '<span>' + day + '</span>天<span>' + toDouble(hour)+'</span>:<span>' +toDouble(minute) + '</span>:<span>' +toDouble(second) + '</span>'; $('#countDowntime').html(strtime) } else { window.clearInterval(int); } }, 1000) } function toDouble(num){ if(num < 10){ return '0'+ num; }else{ return '' + num; } } $(function(){ countDown(); }) </script>
评论 (0 )
最新评论
暂无评论
赶紧努力消灭 0 回复