HBCMS更多的中文手册参考:

childNodes Collection

DHTML文档教程

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.

dhtml语法

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

DHTML可能的值

oCollArray containing the children of a specified object.
oObjectReference to an individual item in the array of elements contained by the object.
iIndexRequired. Integer that specifies the zero-based index of the item to be returned.

Members Table

PropertyDescription
length Sets or retrieves the number of objects in a collection.
MethodDescription
item Retrieves an object from the childNodes or children collection.
urns Retrieves a collection of all objects to which a specified behavior is attached.

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;

是否符合公共标准

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

Applies To

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

更多语法参考

About the W3C Document Object Model