JavaScript 4 DOM



DOMとは?


Document Object Modelの略で、JavascriptとHTML+CSSのインタフェースを表します.

Important Selector Methods.

document.getElementById();
document.getElementsByClassName()
document.getElementByTagName(); //ex. <li>, <h1>
document.querySelector(); // first element
document.querySelectorAll();

使用例

//SELECT
var tag = document.getElementById("highlight");

tag.style.color = "blue";
tag.style.border = "10px solid red";
tag.style.fontSize = "70px";
tag.style.background = "yellow";
tag.style.marginTop = "200px";
//tag.textcontent : 텍스트만을 가져옴
//tag.innerHTML : <></> 태그도 가져옴
https://velog.io/@hyounglee/TIL-14