본문 바로가기

JS/learned_it_today

배열과 반복문 활용

 <h1><a href="index.html">WEB</a></h1>
    <input
      id="night_day"
      type="button"
      value="night"
      onclick="
    var target = document.querySelector('body');
    if(this.value === 'night'){
      target.style.backgroundColor = 'black';
      target.style.color = 'white';
      this.value = 'day';

      var alist = document.querySelectorAll('a');
      var i = 0;
      while(i < alist.length){
        alist[i].style.color = 'powderblue';
        i = i + 1;
      }
    } else {
      target.style.backgroundColor = 'white';
      target.style.color = 'black';
      this.value = 'night';

      var alist = document.querySelectorAll('a');
      var i = 0;
      while(i < alist.length){
        alist[i].style.color = 'blue';
        i = i + 1;
      }
    }
  "
    />
    <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>
      JavaScript (/ˈdʒɑːvəˌskrɪpt/[6]), often abbreviated as JS, is a
      high-level, dynamic, weakly typed, prototype-based, multi-paradigm, and
      interpreted programming language. Alongside HTML and CSS, JavaScript is
      one of the three core technologies of World Wide Web content production.
      It is used to make webpages interactive and pr
    </p>

'JS > learned_it_today' 카테고리의 다른 글

객체 - 반복문과 객체  (0) 2020.05.19
객체 - 쓰기와 읽기  (0) 2020.05.19
배열과 반복문  (0) 2020.05.19
조건문의 활용 + refactoring  (0) 2020.05.19
HTML과 JavaScript의 만남 (이벤트)  (0) 2020.05.19