Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


childNodes Collection

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

What's New for Microsoft® Internet Explorer 6

This collection now applies to the attribute object.

Syntax

[ oColl = ] object . childNodes
[ oObject = ] object .childNodes( iIndex )

Possible Values

oColl Array containing the children of a specified object.
oObject Reference to an individual item in the array of elements contained by the object.
iIndex Required. Integer that specifies the zero-based index of the item to be returned.

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 will encounter TextNode objects in unexpected places, in place of line breaks, for example. Alternately, if you create an element via the Document Object Model (DOM), Internet Explorer will not create extraneous 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 ;

Standards Information

This collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .

Applies To

[ Object Name ] Platform Version
Win16:
Win32:
Unix:
Mac:
Windows CE:
 
A , ACRONYM , ADDRESS , APPLET , AREA , attribute , B , BASE , BASEFONT , BDO , BIG , BLOCKQUOTE , BODY , BUTTON , CAPTION , CENTER , CITE , CODE , COL , COLGROUP , COMMENT , DD , DEL , DFN , DIR , DIV , DL , document , DT , EM , EMBED , FIELDSET , FONT , FORM , FRAME , FRAMESET , HEAD , hn , HR , HTML , I , IFRAME , IMG , INS , KBD , LABEL , LEGEND , LI , LINK , LISTING , MAP , MARQUEE , MENU , nextID , OL , OPTION , P , PLAINTEXT , PRE , Q , S , SAMP , SCRIPT , SELECT , SMALL , SPAN , STRIKE , STRONG , SUB , SUP , TABLE , TBODY , TD , TEXTAREA , TFOOT , TH , THEAD , TITLE , TR , TT , U , UL , VAR , XMP
Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.