www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 getNamedItem Method
getNamedItem Method

Gets an attribute specified with the name property by using the attributes collection.

Syntax

oGetName = attributes.getNamedItem(sGetName)

Parameters

sGetName Required. A String that specifies the name of the attribute to get.

Return Value

Returns an attribute with the specified name.

Remarks

getNamedItem was introduced in Microsoft Internet Explorer 6.

If the attribute applies to an element but is not specified, this method returns the attribute with the specified name set to an empty string.

If the attribute does not apply to the element and is not specified, then an error is returned.

If the attribute does not apply to the element and is specified, then the attribute with the specified name is returned.

Example

The following example shows how to use the getNamedItem method to retrieve the value of an attribute.

<HTML>
<HEAD>
<SCRIPT>
function Init()
{
    var oAttrColl = oElem.attributes;
    var oAttr = oAttrColl.getNamedItem("align");
    alert("ALIGN attribute value: " + oAttr.value);
}
</SCRIPT>
</HEAD>
<BODY >
<P ID="oElem" ALIGN="center">An element.</P>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 6 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

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

Applies To

attributes
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG