var hour = document.querySelector('.hours');
var minute = document.querySelector('.minutes');
var second = document.querySelector('.seconds');
var nowTime = +new Date();
var defineTime = +new Date('2021-9-25 8:0:0');
var chas = defineTime - nowTime;
fn();
var times = setInterval(fn, 1000);
function fn() {
var h = parseInt((chas % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var m = parseInt((chas % (1000 * 60 * 60)) / (1000 * 60));
var s = parseInt((chas % (1000 * 60)) / 1000);
h = h < 10 ? h = '0' + h : h;
m = m < 10 ? m = '0' + m : m;
s = s < 10 ? s = '0' + s : s;
if (s > 0) {
hour.innerHTML = h;
minute.innerHTML = m;
second.innerHTML = s;
} else {
clearInterval(times);
}
}
if前面打印下,看下s的值