Correction status:Uncorrected
Teacher's comments:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>日期倒计时</title> <style type="text/css"> *{margin:0;padding: 0} div{ font-size: 40px; width: 1200px; height: 200px; margin:100px auto; background:green; line-height: 180px; color: #fff; text-align: center; } </style> <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"> </script> </head> <body> <div id='box'> <p>2019年劳动节倒计时:<span></span></p> </div> <script> $(document).ready(function(){ function countDown(){ var d=Date.parse("May 01,2019"); // console.log(d); var date=new Date(); var dd=date.getTime(); var rd=Math.floor((d-dd)/1000); var days=Math.floor(rd/86400); var hours=Math.floor(rd%86400/3600); var minutes=Math.floor(rd%3600/60); var seconds=Math.floor(rd%60); $('span').text(days+'天'+hours+'小时'+minutes+'分'+seconds+'秒') // console.log(hours); } setInterval(countDown,1); }) </script> </body> </html>
点击 "运行实例" 按钮查看在线实例