1. childNodes 내려서 썻을때 ```html

Ex4: childNodes를 이용한 노드 선택

<hr/> ``` ```js // Ex4: childNodes를 이용한 노드 선택 window.addEventListener("load",function(){
var section4= document.querySelector("#section4");
var box=section4.querySelector(".box");

var input1=box.childNodes[0];
var input2=box.childNodes[1];
 
input1.value ="hello";
input2.value="okay"; }); ``` ![node1](/assets/images/node1.JPG) - childNodes 를 썼을 때  빈공백도 노드여서 node로 들어간다. 따라서 상자를 내려썼을때 값이 공백이 1번째값이되서 값이 밀리게되는것이다. ->빈공백도 자식으로 취함
  1. childNodes 붙여서 썻을때 ```html

Ex4: childNodes를 이용한 노드 선택

```js
// Ex4: childNodes를 이용한 노드 선택
window.addEventListener("load",function(){
    var section4= document.querySelector("#section4");
    var box=section4.querySelector(".box");
    
    var input1=box.childNodes[0];
    var input2=box.childNodes[1];
 
    input1.value ="hello";
    input2.value="okay";
});

node2

  1. children 썻을때 ```html

Ex4: childNodes를 이용한 노드 선택


```js
// Ex4: childNodes를 이용한 노드 선택
window.addEventListener("load",function(){
    var section4= document.querySelector("#section4");
    var box=section4.querySelector(".box");
    
    var input1=box.children[0];
    var input2=box.children[1];
 
    input1.value ="hello";
    input2.value="okay";
});

node2

  • children은 태그형태로되어있는것만 자식으로만 취한다.

댓글남기기