less than 1 minute read

DOM에서 요소를 생성 및 수정, 삭제를 할 수 있다.

아래는 위의 기능을 수행할 수 있는 속성/메서드 7가지를 소개한다.

1. document.createElement(“”);

요소 생성하기 createElement

2. Element.children

자식 요소 가져오기 children

3. Element.classList

요소의 클래스 정보 classList

4. Element.innerHTML

요소의 HTML innerHTML

5. Element.style

요소의 CSS 스타일 style

6. Element.remove

요소 삭제하기 remove

7. Element.appendChild

자식 요소 추가하기 appendChild

위의 예시들은 JS Bin에서 테스트한 것이다.

Leave a comment