How to use DOM Element getAttributeNode in JavaScript

In this article I am going to explain about DOM element getAttributeNode() Method in JavaScript.
  • 1455

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.


element.getAttributeNode(attribute name)




    <script type="text/javascript">

        function myfun() {

            var a = document.getElementsByTagName("a")[0];

            var p = document.getElementById("tst");

            p.innerHTML = a.getAttributeNode("target").value;





    <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>






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


More Articles

© 2020 DotNetHeaven. All rights reserved.