Javascript examples for DOM HTML Element:Anchor
The Anchor object represents an HTML <a> element.
You can access an <a> element by using getElementById():
<!DOCTYPE html> <html> <body> <a id="myAnchor" href="https://www.java2s.com">Tutorials</a> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww .java 2 s.c om var x = document.getElementById("myAnchor").href; document.getElementById("demo").innerHTML = x; } </script> </body> </html>