HBCMS更多的中文手册参考:

item Method

DHTML文档教程

Retrieves an object from the all collection or various other collections.

dhtml语法

oitem = object.item(vindex [, isubindex])

parameters

vIndex Required. Integer or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made.
iSubindex Optional. Integerthat specifies the zero-based index of the object to retrieve when a collection is returned.

Return Value

Returns an object or a collection of objects if successful, or null otherwise.

Remarks

The item method cannot retrieve input type=image elements from a form. to access all elements contained in a form, use the children collection.

Examples

The following example uses the item method to retrieve each object from the document. In this case, the method parameter is a number, so the objects are retrieved in the order they appear in the document.

<SCRIPT LANGUAGE="JScript">
var coll = document.all;
if (coll!=null) {
for (i=0; i<coll.length; i++)
alert(coll.item(i).tagName);
}
</SCRIPT>

The next example uses the item method to retrieve a collection of all objects in the document that have "Sample" as an id. the example then uses item again to retrieve each object from the "sample" collection.

<script language="jscript">
var coll = document.all.item("Sample");
If (coll != null) {
for (i=0; i<coll.length; i++) {
alert(coll.item(i).tagName);
}
}
</SCRIPT>

The last example is similar to the previous example, but uses the optional iSubindex parameter of item to retrieve individual objects.

<SCRIPT LANGUAGE="JScript">
var coll = document.all.item("Sample")
if (coll!=null) {
for (i=0; i<coll.length; i++)
alert(document.all.item("Sample",i).tagName);
}
</SCRIPT>

是否符合公共标准

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

Applies To

all, anchors, applets, areas, boundElements, cells, elements, embeds, forms, images, links, mimeTypes, options, plugins, rows, scripts, tBodies, FORM