Retrieves an object or a collection from the specified collection.
dhtml语法
oItem = object.namedItem(sName)
Parameters
sName |
Required.
String that specifies the name or id property of the object to retrieve. a collection is returned if more than one match is made. |
return value
returns an object or a collection of objects if successful, or null otherwise.
remarks
this method first searches for an object with a matching id attribute. if a match is not found, the method then searches for an object with a matching name attribute, but only on those elements that are allowed a name attribute.
DHTML代码范例
The following example shows how to use the namedItem method to retrieve a div and change its innertext property.
<div id="odiv1">This text will not change.</DIV>
<DIV id="oDIV2">This text will change.</DIV>
<BUTTON onclick="document.all.namedItem('oDIV2').innerText='Changed!';">
Change Option
</BUTTON>
是否符合公共标准
This method is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
|
all,
anchors,
applets,
areas,
boundElements,
cells,
elements,
embeds,
forms,
images,
links,
mimeTypes,
options,
plugins,
rows,
scripts,
tBodies,
FORM,
filters,
frames,
imports,
styleSheets,
TextRange,
TextRectangle |
|