반응형
[출처-유튜브 노마드 코더 Nomad Coders]
-이론 끝. 이제 momentum을 만들자

index.html
<!DOCTYPE html>
<html>
<head>
<title>Something</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div class="js-clock">
<h1>00:00</h1>
</div>
<script src="clock.js"></script>
</body>
</html>
clock.js
const clockContainer = document.querySelector(".js-clock"),
clockTitle = clockContainer.querySelector("h1");
function getTime(){
const date = new Date();
const minute = date.getMinutes();
const hours = date.getHours();
const seconds = date.getSeconds();
clockTitle.innerText = `${hours}:${minute}:${seconds}`;
}
function init(){
getTime();
}
init();

반응형
'JavaScript > Vanilla JS' 카테고리의 다른 글
| [바닐라JS로 크롬 앱 만들기] Saving the User Name part One (0) | 2021.02.26 |
|---|---|
| [바닐라JS로 크롬 앱 만들기] Making a JS Clock part Two (0) | 2021.02.26 |
| [바닐라JS로 크롬 앱 만들기] DOM - If else - Function practice Two (0) | 2021.02.26 |
| [바닐라JS로 크롬 앱 만들기] DOM - If else - Function practice (0) | 2021.02.26 |
| [바닐라JS로 크롬 앱 만들기] If, else, and, or (0) | 2021.02.26 |
댓글