-
createElement (생성)
-
add (추가)
-
innerHTML HTML 또는 XML 마크업을 가져오거나 설정 // (XSS 공격의 위험이 있음)
-
textContent 텍스트 노드로 대체 (XSS 공격의 위험이 없음)
-
appendChild (부모 노드의 자식 노드 리스트 중 마지막 자식노드에 삽입)
-
prepend (첫 자식노드 앞에 삽입)
사용 예
let testBox = document.createElement('div') // tag명
testBox.classList.add('.commandBox') // id, class 명
testBoxinnerHTML = comment.user // comment 파라메타에 속한 user
testBox.textContent = comment.user // comment 파라메타에 속한 user
childBox.appendChild(testBox) // testBox 밑에 childBox 맨 뒤에 삽입
childBox.prepend(testBox) // testBox 밑에 childBox 상단에 삽입
'CodeStates > └ DOM' 카테고리의 다른 글
DOM 조작 (<template> 태그) (0) | 2020.07.06 |
---|---|
DOM 조작 (메소드) (0) | 2020.07.06 |
DOM 조작 (inner HTML) (0) | 2020.07.06 |
DOM (클릭 이벤트) (0) | 2020.07.06 |
DOM (HTML 구조 접근) (0) | 2020.07.06 |
댓글