
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
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 −
- Related Articles
- HTML DOM Anchor Collection
- HTML DOM Anchor protocol Property
- HTML DOM Anchor password Property
- HTML DOM Anchor pathname Property
- HTML DOM Anchor href Property
- HTML DOM Anchor origin Property
- HTML DOM Anchor port Property
- HTML DOM Anchor hreflang Property
- HTML DOM Anchor download Property
- HTML DOM Anchor hash Property
- HTML DOM Anchor rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property

Advertisements