Retrieves an attribute node by name.
Method of dom/Elementdom/Element
Syntaxvar attributeNode = element.getAttributeNode();
Return Value
Returns an object of type DOM NodeDOM Node
An attribute node.
ExamplesThe following example uses getAttributeNode to create an attribute and populate its div element. Note how the call to setAttribute changes the href value for the content attribute but not for the DOM attribute.
<!doctype html>
<html>
<head>
<title>Attribute Node Example</title>
<base href="http://msdn.microsoft.com/">
<script>
function GetAttrNode() {
var o = document.getElementById("msdn");
var sDomAttr = o.href;
o.setAttribute('href', 'en-us/ie/default.aspx');
var sContentAttr = o.getAttributeNode("href");
var sOutput = ("Content attribute node value: " + sContentAttr.value +
"<br/>DOM attribute value: " + sDomAttr);
document.getElementById("output").innerHTML = sOutput;
}
</script>
</head>
<body>
<a id="msdn" href="en-us/default.aspx">Microsoft Developer Network</a>
<div id="output" onmouseover="GetAttrNode()">Point here to display attribute values.</div>
</body>
</html>
Related specifications
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4