Gets a collection of direct Node descendants of the Node, including Element, Text and any other type of nodes.
SyntaxNote: 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.
ExamplesThis 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.
AttributionsMozilla Developer Network : [Node.childNodes Article]
Microsoft Developer Network: [childNodes Property Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4