반응형 element.children1 [JavaScript] element.childNodes, element.children, Node.contain 오늘은 element.childNodes, element.children, Node.contain에 대해서 공부했다. 동적으로 생성한 html 요소를 조회하는데 유용한 기능들이었다. element.childNodes 는 주어진 요소의 자식 노드 모음( collection )을 반환해주고, element.children은 호출된 요소의 모든 자식 노드의 elements를 담고있는 실시간 HTMLCollection을 반환한다. (비 요소 노드 제외) childNodes와 children의 역할이 헷갈려서 둘의 차이를 알아봤는데 childNodes의 경우 요소가 아닌 비 요소 노드도 포함해주는 반면, element.children은 요소 노드만 배열 형태로 반환해준다. (HTML DOM은 노드(node)라고 .. 2020. 10. 5. 이전 1 다음 반응형