js 1

Lima·2021년 1월 27일
0
const clockContainer = document.querySelector(".js-clock");  
const clockTitle = clockContainer.querySelector("h1");

function getTime(){
    const date = new Date();
    const min = date.getMinutes();
    const hour = date.getHours();
    const sec = date.getSeconds();
    clockTitle.innerText = 
    `${hour<10?`0${hour}`:hour}:${min<10?`0${min}`:min}:${sec <10 ? `0${sec}`: sec}`;
}

function init(){
    getTime(); 
    setInterval(getTime,1000);
}

init();

0개의 댓글