Latest web development tutorials

HTML DOM getAttributeNode () method

Elements Object Reference Element object

Examples

Return Link target attribute:

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

try it"

Definition and Usage

getAttributeNode () method to get an attribute node by name from the current element.

Tip: If you only want to return property values, use getAttribute method.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support getAttributeNode () method


grammar

element.getAttributeNode( attributename )

parameter

参数 类型 描述
attributename String 必须。你想返回的属性名。

return value

类型 描述
Attr object 指定的属性节点

technical details

DOM version Core Level 1 Element Object


Elements Object Reference Element object