childNodes
Summary
Gets a collection of direct Node descendants of the Node, including Element, Text and any other type of nodes.
Syntax
Note: This property is read-only.
var result = element.childNodes;
Return Value
Returns an object of type
A live collection of the direct Node descendants of the Node.
Examples
This example shows how to assign to a variable the childNodes collection of the body object.
<script>
var aNodeList = oBody.childNodes;
</script>
<body id="oBody">
<span id="oSpan">A Span</span>
</body>
This example shows how to assign to a variable the childNodes collection of a node created with the createElement method.
var oParentNode = document.createElement("DIV");
var oNode = document.createElement("B");
document.body.insertBefore(oParentNode);
oParentNode.insertBefore(oNode);
var aNodeList = oParentNode.childNodes;
Notes
The childNodes collection can contain Element and Text nodes. If you check the childNodes collection of an element created through standard HTML, you encounter Text nodes in unexpected places—in place of line breaks, for example. Alternately, if you create an element using the Document Object Model (DOM), no unintended Text nodes are created.
Attributions
Mozilla Developer Network : [Node.childNodes Article]
Microsoft Developer Network: [childNodes Property Article]