강의 내용
- 태그를 제어하는 대표적인 방법으로는 아래와 같다.
1) Document.querySelect(): 제공한 선택자 또는 선택자 뭉치와 일치하는 문서 내 첫 번째 element를 반환. 일치하는 요소가 없으면 null을 반환.
2) Document.getElementById(): 주어진 문자열과 일치하는 id 속성을 가진 요소를 찾고, 이를 나타내는 element 객체를 반환. ID는 문서 내에서 유일해야 하기 때문에 특정 요소를 빠르게 찾을 때 유용.
3) Document.getElementsByClassName(): 주어진 클래스 이름을 모두 가진 모든 자식 요소의 배열과 유사한 개체를 반환.
4) Document.getElementsByName(): 문서에서 주어진 속성을 가진 요소의 컬렉션을 반환.
강의 실습 코드
<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>
출처 & 깃허브
생활코딩 web/html&internet
github