HBCMS更多的中文手册参考:

getNamedItem Method

DHTML文档教程

Retrieves an attribute specified with the name property using the attributes collection.

dhtml语法

ogetname = attributes.getnameditem(sgetname)

parameters

sGetName Required. String that specifies the name of the attribute to retrieve.

Return Value

Returns an attribute with the specified name.

Remarks

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.

DHTML代码范例

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 ONLOAD="Init()">
<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.

是否符合公共标准

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

Applies To

attributes