jQuery 倒计时 非常简单
2018-6-5 金莎网 JavaScript
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <span id="timespan"></span> </body> </html> <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script> <script> var starttime = new Date("2020/11/20"); setInterval(function () { var nowtime = new Date(); var time = starttime - nowtime; var day = parseInt(time / 1000 / 60 / 60 / 24); var hour = parseInt(time / 1000 / 60 / 60 % 24); var minute = parseInt(time / 1000 / 60 % 60); var seconds = parseInt(time / 1000 % 60); $("#timespan").html(day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒"); }, 1000); </script>