Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM getAttributeNode() method

HTML DOM getAttributeNode() method

Element Object Reference Element object

Example

Return the target attribute of the link:

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

Try it »


Definition and Usage

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

**Tip:** If you only want to return the attribute value, please use the getAttribute method.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getAttributeNode() method


Syntax

element

.getAttributeNode(

attributename

)

Parameters

Parameters 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 Reference Element object