Javascript examples for DOM HTML Element:Anchor
Anchor href Property - get the URL of a link for a relative URL
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" href="default.asp">JavaScript and HTML DOM Reference</a></p> <button onclick="myFunction()">display the value of the href attribute of the link above</button> <p id="demo"></p> <script> function myFunction() {//w w w. j av a 2 s. c o m var x = document.getElementById("myAnchor").href; document.getElementById("demo").innerHTML = x; } </script> </body> </html>