HTML DOM - problem with a div
So I've this little code:
Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="first">
<p>Hello</p>
</div>
<script>
var x=document.getElementById("first");
alert(x.firstChild.innerHTML);
</script>
</body>
</html>
As far as I understand, the <p> inside the <div> should be its child, and in this case the first and last child. In that case, the script should alert "Hello" since it's the innerHTML of the <p> element.
Obviously I'm missing something and would love to be enlightened.
Thanks.