JavaScript/끄적끄적

2. childNodes, children

깍돌이 2017. 12. 4. 18:26

children 과 childNodes 를 비슷해보이지만 결과값이 다르다



var child_array2 = window.document.getElementById("layout");

var nodes = child_array2.childNodes;

console.log(nodes);

nodes = child_array2.children;

     console.log(nodes);



사진을 보면 childNodes는 25개의 결과 가 나오지만  children 은 12개의 결과 가 나옵니다.


childNodes는  줄바꿈을 개수로 세는 경우가 있어서 해당과 같이 나옵니다.



자세한건 없고 되도록  children 을 쓰려고합니다.