HTML DOM getAttributeNode()Method

元素对象参考手册Element Object

Examples

Return the target attribute of the link:

document.getElementsByTagName("a")[0].getAttributeNode("target");

Try it Yourself »

Definition and Usage

The getAttributeNode() method gets the attribute node from the current element by name.

Tip:If you only want to return the attribute value, use thegetAttributemethod.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getAttributeNode() method


Syntax

element.getAttributeNode(attributename)

Parameters

Parameter Type Description
attributename String Required. The name of the attribute you want to return.

Return Value

Type Description
Attr object The specified attribute node

Technical Details

DOM Version Core Level 1 Element Object


元素对象参考手册Element Object

Other Extensions