I'm just learning javascript but this is very confusing to me.
I am trying to learn how the childNodes property works. I am using it on a div with three h1 tags in it and nothing else, yet it is returning 7 child nodes. Why is this?
https://jsfiddle.net/xyzL65Lv/
html:
<head>
<title>Learn Javascript</title>
</head>
<body>
<div>
<h1 id="title">one</h1>
<h1 id="title2">two</h1>
<h1 id="title3">three</h1>
</div>
</body>
javascript:
parent = document.getElementsByTagName("div");
children = parent[0].childNodes;
for(var i=0; i<children.length; i++){
document.write("#" + i + " " + children[i].innerHTML + "<br>");
}