본문 바로가기

프론트엔드/js

[생활코딩 WEB2 JS 15강] 비교 연산자와 블리언, 조건문 , 토글키 만들기

 

 

오늘은 토글키를 만들어봤다.

생활코딩센세 만세다.

정말 삐약이 수준의 눈높이 강의를 해주셔서

그리고 댓글달아주시는 분들도 내 궁금증을 등 긁어주듯이 긁어주셔서 너무나 명쾌하게 해결하였다.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1><a href="index.html">WEP</a></h1>
    <input
      type="button"
      value="다크모드"
      onclick="document.querySelector('body').style.
      backgroundColor = 'black'
      document.querySelector('body').style.color = 'white'"
      ;
    />

    <input
      type="button"
      value="아침모드"
      onclick="document.querySelector('body').style.
      backgroundColor = 'white'
      document.querySelector('body').style.color = 'black'"
      ;
    />

    <input
      id="togle"
      type="button"
      value="다크모드"
      onclick="
    if(document.querySelector('#togle').value ==='다크모드')
    {
    document.querySelector('body').style.backgroundColor = 'black';
    document.querySelector('body').style.color = 'white';
    document.querySelector('#togle').value='아침모드';
   
    } else {
    document.querySelector('body').style.
    backgroundColor = 'white';
    document.querySelector('body').style.
    color = 'black';
    document.querySelector('#togle').value='다크모드';

    }
    "
    />

    <ol>
      <li><a href="1.html">HTML</a></li>
      <li><a href="2.html">CSS</a></li>
      <li><a href="3.html">JavaScript</a></li>
    </ol>
    <h2>JavaScript</h2>
    <p>이것이 자바다.</p>
  </body>
</html>