Get the value of the target attribute node of an <a> element:
Click the button to display the value of the target attribute node of the link above.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from www . j a v a2 s. co m*/ var elmnt = document.getElementById("myAnchor"); var attr = elmnt.getAttributeNode("target").value; document.getElementById("demo").innerHTML = attr; } </script> </body> </html>