DOM(Document Object Model)이란?
- DOM은 HTML용 표준 객체 모델이자 프로그래밍 인터페이스
- DOM 모델은 객체 트리로 구성
- DOM은 객체로서의 HTML 요소와 속성, 요소에 엑세스 방법, 이벤트 등을 정의
- DOM은 HTML 요소에 접근, 변경, 추가, 삭제 등의 방법에 대한 표준
const TITLE = document.getElementById('title')
TITLE.style.color = 'red';
const H1 = document.getElementsByTagName('h1');
H1[1].style.color = 'green';
H1[1].style.fontSize = '3rem';
H1[1].style = 'color: pink; font-size: 5rem;';
const CLASS_ELE = document.getElementsByClassName('none-li');
const CSS_ID = document.querySelector('#title');
const CSS_CLS_ALL = document.querySelectorAll('.none-li');
const LI = document.getElementsByTagName('li')
LI[1].style.backgroundColor = 'pink';
const CSS_CLS2 = document.querySelectorAll('li:nth-child(2)');
const CSS_CLS3 = document.querySelectorAll('ul > li:nth-child(2)');
CSS_CLS_ALL.forEach(node => node.style.color = 'purple')
TITLE.textContent = '집가고싶당';
TITLE.innerHTML = '<a>링크</a>';
const INPUT1 = document.querySelector('input');
INPUT1.setAttribute('placeholder', '인풋입니다');
INPUT1.removeAttribute('placeholder');
TITLE.style.color = 'red';
TITLE.removeAttribute('style');
TITLE.classList.add('font-color-red');
TITLE.classList.add('font-color-red', 'css2', 'css3', 'css4');
TITLE.classList.remove('font-color-red');
TITLE.classList.toggle('font-color-red');