namedItem method (Internet Explorer)

Switch View :
ScriptFree
namedItem method

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

Retrieves an object or a collection from a specified collection.

Syntax

object.namedItem(name)

Standards information

There are no standards that apply here.

Parameters

name [in]

Type: BSTR

A 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

Type: ObjectReturns an object or a collection of objects if successful, or null otherwise.

Remarks

Windows Internet Explorer 8 and later. In IE8 Standards mode, the namedItem method does not return collections if more than one named item is found; instead, it returns the first case-insensitive matched element. For more information on IE8 mode, see Defining Document Compatibility.

The namedItem method was introduced in Microsoft Internet Explorer 6.

The namedItem method does not return collections if more than one named item is found; instead, it returns the first case-insensitive matched element.

This method first searches for an object with a matching id attribute. If a match is not found, the method searches for an object with a matching name attribute, but only on those elements that are allowed a name attribute.

Examples

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').innerHTML='Changed!';">
   Change Option
</button>

 

 

Build date: 3/8/2012