childNodes property

This topic has not yet been rated - Rate this topic

Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.

Syntax

JavaScript

p = object.childNodes

Property values

Type: Object

Array containing the children of a specified object.

Standards information

There are no standards that apply here.

Remarks

The childNodes collection can contain HTML Element and TextNode objects.

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;

See also

About the W3C Document Object Model

 

 

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.