728x90
    
    
  childNodes 프로퍼티를 사용하면 유사배열(NodeList) 형태로 자식 노드들을 가져올 수 있다. 여기서 가져올 수 있는 노드들은 childNodes를 사용할 리시버 객체의 직접적인 자식이다. 다음과 같은 노드들을 직접적인 자식이라 한다.
| 
 1 
2 
3 
4 
5 
6 
7 
8 
 | 
 <div id="a"> 
    <!--id가 b인 div는 id가 a인 div의 직접적인 자식--> 
    <div id='b'> 
        <!--여기있는 h1, h2는 id가 a인 div의 직접적인 자식이 아니다--> 
        <h1>e</h1> 
        <h2>r</h2> 
    </div> 
</div> 
 | 
cs | 
childNodes는 Element 노드들 뿐만 아니라 다른 노드들도 포함한다.
출처: DOM Elightement
'java script > DOM' 카테고리의 다른 글
| 1.15 Converting a NodeList or HTML Collection to a JavaScript Array (0) | 2021.09.25 | 
|---|---|
| 1. 13 Grokking Node Collections(i.e. NodeList and HTMLCollection) (0) | 2021.09.02 | 
| 1.12 Using cloneNode() to Clone Nodes (0) | 2021.09.01 | 
| 1.11 Using removeChild() and replaceChild() to Remove and Replace Nodes (0) | 2021.08.31 | 
| 1.10 Using appendChild() and insertBefore() to Add Node Objects to the DOM (0) | 2021.08.29 |