- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Anchor Object
The <a> element is used in HTML to create hyperlinks along with href attribute. The anchor object represents this <a> element.
Example
In the below example, we will learn how to access an anchor object −
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <a href="https://google.com" id = "myid" >Google</a><br><br> <button onclick="display()">Display the link</button> <p id="demo">Link gets displayed here</p> <script> function display() { var a = document.getElementById("myid").href; document.getElementById("demo").innerHTML = a; } </script> </body> </html>
Output
This will produce the following output −
Advertisements