HTML DOM getAttributeNode()Method
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
![]()
![]()
![]()
![]()
![]()
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 |
|---|
Other Extensions
Element Object