实例 jquery完成的倒计时
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>倒计时</title> <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script> <style type="text/css" media="screen"> *{ margin: 0; padding: 0; } img{ border:0; } ol, ul ,li{list-style: none;} #kk{ width:1000px; height:100px; line-height: 100px; background: #039293; color:#fff; font-size: 40px; text-align:center; margin:100px auto; } </style> </head> <body> <div id="kk"> <p>距离劳动节还有:<span></span></p> </div> <script> $(function(){ function Ro(){ //当前时间戳 var d = new Date().getTime(); //1970年的时间戳 var dd = new Date("2019-05-01 0:0:0").getTime(); //获取今天距离劳动节的总毫秒 var times = dd-d; //获取天数 var get_days = Math.floor(times/1000/3600/24); //获取小时 var get_hours = Math.floor((times/1000/3600)%24); //获取分钟 var get_minutes = Math.floor((times/1000/60)%60); //获取秒 var get_seconds = Math.floor((times/1000)%60); $('#kk span').text(get_days+'天'+get_hours+'时'+get_minutes+'分'+get_seconds+'秒'); } setInterval(Ro,1000); }) </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例