The problem is that I would suggest iterating over children and finding the actual shorthand. That's one of the reasons why people love jQuery so much:parent
TextNode
containing a new line after parent
opening tag, the actual child
TextNode
with newline after closing child
tag. But hard-coding second item is a bad idea:
var parent = document.getElementById("parent");
console.info(parent.childNodes.length);
var child = parent.childNodes[1];
var childval = child.innerHTML;
child
or using parent.getElementsByTagName('div')
$('#parent div').text()