<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"; }); ```  - childNodes 를 썼을 때 빈공백도 노드여서 node로 들어간다. 따라서 상자를 내려썼을때 값이 공백이 1번째값이되서 값이 밀리게되는것이다. ->빈공백도 자식으로 취함
```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";
});
```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";
});
댓글남기기