Note

노마드코더 바닐라 JS 챌린지 10일차 본문

#학습/AI&IT

노마드코더 바닐라 JS 챌린지 10일차

참잘했을까요? 2021. 9. 2. 00:01
반응형

확실히 늙었나 보다 예전엔 평균 수면시간 4시간이면 거뜬 했는데..........내일은 버스타고 가면서 좀 자야 겠ㄷ....

 

// 5초마다 입력중

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="css/style.css" />
    <title>Momentum App</title>
  </head>
  <body>
    <form class="hidden" id="login-form">
      <input
        required
        maxlength="15"
        type="text"
        placeholder="What is your name?"
      />
      <input type="submit" value="Log In" />
    </form>
    <h2 id="clock">00:00</h2>
    <h1 class="hidden" id="greeting"></h1>
    <script src="js/greetings.js"></script>
    <script src="js/clock.js"></script>
  </body>
</html>
const clock = document.querySelector("h2#clock");

function sayHello() {
  console.log("hello");
}

setInterval(sayHello, 5000); b

const clock = document.querySelector("h2#clock");

function getClock() {
  const date = new Date();
  clock.innerText = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
}

getClock();
setInterval(getClock, 1000);

// !!! 드디어 작동됨!!!! console.log 짱임.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Momentum App</title>
  </head>
  <body>
    <form class="hidden" id="login-form">
      <h1>Time Until Christmas Eve</h1>
    
    
    </form>
    <h2 id="clock">00d 00h 00m 00s</h2>
    <h1 class="hidden" id="greeting"></h1>
    <script src="clock.js"></script>
  </body>
</html>
const clock = document.querySelector("h2#clock");

function getClock() {
  const date = new Date();
  clock.innerText = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
}

getClock();
setInterval(getClock, 1000);

https://codesandbox.io/s/a08blueprint-forked-2jxzu?file=/index.html 

 

a08Blueprint (forked) - CodeSandbox

a08Blueprint (forked)

codesandbox.io

 

반응형
Comments