Javascript examples for DOM:Document anchors
Document anchors Collection - Get the HTML content of the first <a> element in the document:
<!DOCTYPE html> <html> <body> <a name="html">HTML Tutorial</a><br> <a name="css">CSS Tutorial</a><br> <a name="xml">XML Tutorial</a><br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . ja va 2 s.c o m*/ var x = document.anchors[0].innerHTML; document.getElementById("demo").innerHTML = x; } </script> </body> </html>