Get the value of the target attribute of an <a> element:
var x = document.getElementById("myAnchor").getAttribute("target");
Click the button to display the value of the target attribute of the link above.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w w w . ja v a2 s. c o m*/ var x = document.getElementById("myAnchor").getAttribute("target"); document.getElementById("demo").innerHTML = x; } </script> </body> </html>