How to use DOM Element getAttributeNode in JavaScript
In this article I am going to explain about DOM element getAttributeNode() Method in JavaScript.
JavaScript DOM Element getAttributeNode() Method
JavaScript getAttributeNode() method use for get the Information about attribute node object and its also use for get the attribute with specified name.
Syntax
element.getAttributeNode(attribute name)
|
Example
<html>
<head>
<script type="text/javascript">
function myfun() {
var a = document.getElementsByTagName("a")[0];
var p = document.getElementById("tst");
p.innerHTML = a.getAttributeNode("target").value;
}
</script>
</head>
<body>
<a href="#" target="Main page">click hear</a>.
<p id="tst">
click button for get target name of attribute</p>
<button onclick="myfun()">
click me</button>
</body>
</html>
|
Output
Before click
After click
You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here