要求:在网页中显示当前时间
预览效果:
源码:
let h1 = document.querySelector("h1");
setInterval(()=>{
let timeNow = new Date();
let hours = timeNow.getHours();
let minuts = timeNow.getMinutes();
let seconds = timeNow.getSeconds();
let time = `${hours}:${minuts}:${seconds}`;
h1.innerHTML = time;
},500)