JS Dom - Dom

호니·2023년 5월 22일
0

document.getElementById

var el = document.getElementById("brand-title");

-> 아이디를 통해 요소를 가져오겠다.

console.log(el.innerHTML);

-> HTML 태그만 제거

console.log(el.innerText);

-> Text 자체만 출력

el.innerText = "안녕하세요 :);

document.getElementByClassName

var el2 = document.getElementByClassName('sub-title');

class 값을 갖는 것 가져올 것
(여러 개도 가능)

console.log(el2);
profile
호니의 개발 공부

0개의 댓글