实现一个倒计时功能,显示现在到截止日期之间的时间,并且每一秒都会发生变化 const end = new Date("2020-11-11 00:00"); document.getElementById("deadTime").innerHTML = "2020-11-11 00:00"; function countdown() { let now = new Date(); let day, hour, minute, second, str; let remainder = end - now; if (remainder < 0) { return; } day = Math.floor(remainder / 1000 / 60 / 60 / 24); hour = Math.floor(remainder / 1000 / 60 / 60 % 24); minute = Math.floor(remainder / 1000 / 60 % 60); second = Math.floor(remainder / 1000 % 60); str = `${day}天${hour}时${minute}分${second}秒`; document.getElementById("date").innerHTML = str; setTimeout(countdown, 1000); } countdown();