10 out of 24 rated this helpful - Rate this topic

childNodes property

[This documentation is preliminary and is subject to change.]

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: IDispatch

Array containing the children of a specified object.

Standards information

There are no standards that apply here.

Remarks

The childNodes collection can contain HTML Elements and TextNode objects.

If you check the childNodes collection of an element created through standard HTML, you encounter TextNode objects in unexpected places—in place of line breaks, for example. Alternately, if you create an element using the Document Object Model (DOM), Windows Internet Explorerdoes not create extraneous TextNode objects.

In Microsoft Internet Explorer 6, This collection now applies to the attribute object.

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: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Remark
Note. This is not an Array in the JScript sense: e.g. alert(object.childNodes) does not print out a list of all its array-values.
Applies to OBJECT as well

OBJECT.childNodes are typically PARAM elements and fallback content