JavaScript/생활코딩

WEB2 - JavaScript - 제어할 태그 선택하기

점미 2018. 12. 19. 14:02



제어할 태그 선택하기 - https://opentutorials.org/course/3085/18792



버튼을 클릭 하였을 때 body태그의 style속성이 바뀌도록 하는 태그


<h1><a href="index.html">WEB</a></h1>

  <input type="button" value="night" onclick="

    document.querySelector('body').style.backgroundColor = 'black'; //body태그를 선택하여 배경색을 바꿔준다

    document.querySelector('body').style.color = 'white'; //body태그를 선택하여 글자색을 바꿔준다.

  ">

  <input type="button" value="day" onclick="

    document.querySelector('body').style.backgroundColor = 'white';

    document.querySelector('body').style.color = 'black';

  ">

  <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 provide online programs, including video games. The majority of websites employ it, and all modern web browsers support it without the need for plug-ins by means of a built-in JavaScript engine. Each of the many JavaScript engines represent a different implementation of JavaScript, all based on the ECMAScript specification, with some engines not supporting the spec fully, and with many engines supporting additional features beyond ECMA.

  </p>