Javascript examples for DOM HTML Element:Anchor
Anchor href Property - Get the URL of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" hreflang="en-us" href="https://www.java2s.com/">java2s.com</a></p> <button onclick="myFunction()">test</button> <p id="demo"></p> <script> function myFunction() {/* w ww. j ava 2 s. co m*/ var x = document.getElementById("myAnchor").href; document.getElementById("demo").innerHTML = x; } </script> </body> </html>