Search w3schools.com:

SHARE THIS PAGE

DOM Element getAttributeNode() Method

Element Object Reference Element Object

Example

Return the target attribute of a link:

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

Try it yourself »

Definition and Usage

The getAttributeNode() method returns the attribute with the specified name, as an Attr object.

Read more about the Attr Node object in our Attr Node object reference.

Tip: Use the getAttribute if you just want to return the attribute value.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The getAttributeNode() method is supported in all major browsers.


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 Reference Element Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]