728x90
자바스크립의 문법에 따라서 웹브라우저에게 <body>태그를 선택하게 해야한다면?
JavaScript select tag by css selector 검색
document.querySelector('body')
* query : 질의하다
<body>태그의 <style> 이라는 속성을 어떻게 JS로 넣을수있는가를 검색해야한다면?
JavaScript element style 검색
.style.backgroundColor = 'black';
<h1><a href="index.html">WEB</a></h1>
<input type="button" value="night" onclick="
document.querySelector('body').style.backgroundColor = 'black';
document.querySelector('body').style.color = 'white';
">
<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>
클릭 [야간모드/낮모드]
<input type="button" value="night" onclick="
document.querySelector('body').style.backgroundColor='black';
document.querySelector('body').style.Color='white';
">
↑
onclick = JS 이벤트
728x90
'STUDY > JavaScript' 카테고리의 다른 글
[JavaScript-생활코딩] 11. 조건문 예고 (0) | 2022.06.01 |
---|---|
[JavaScript-생활코딩]10. 프로그램, 프로그래밍, 프로그래머 (0) | 2022.06.01 |
[JavaScript-생활코딩] 8. CSS 기초 (0) | 2022.06.01 |
[JavaScript-생활코딩] 7. 웹브라우저 제어 (0) | 2022.06.01 |
[JavaScript-생활코딩] 6. 변수와 대입 연산자 (0) | 2022.06.01 |