<p class="" id="c_nowTime">加载中~</p> setInterval(() => { var timespan = document.querySelectorAll('#c_nowTime'); var now = new Date(); var nh = now.getHours(); var nm = now.getMinutes(); var ns = now.getSeconds(); if (nh < 10) nh = '0' + nh; if (nm < 10) nm = '0' + nm; if (ns < 10) ns = '0' + ns; [].forEach.call(timespan, function (v) { v.innerHTML = '时间:' + nh + ":" + nm + ':' + ns; }); }, 1000);
简单的 JS 当前时间