

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 hash Property
The HTML DOM Anchor hash property is used to set or return the anchor part of the href attribute value. The part of the URL after the # is what we call the anchor part of a link.
Following is the syntax to set the hash property −
anchorObject.hash = anchor_part
Above, anchor_part is the anchor part of the URL.
Following is the syntax to return the hash property −
anchorObject.hash
Let us now see an example to implement the DOM Anchor hash property −
Example
<!DOCTYPE html> <html> <body> <h1>Company</h1> <p><a id="mylink" href="http://www.demo.com/abc/def.html#myteam">Our Team</a></p> <p>Get the anchor part...</p> <h2 id="myid"></h2> <button onclick="display()">Display Anchor Part</button> <script> function display() { var a = document.getElementById("mylink").hash; document.getElementById("myid").innerHTML = a; } </script> </body> </html>
Output
Now, click on the button to display the anchor part of the link −
- Related Questions & Answers
- 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 rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property
- HTML DOM Anchor username Property
- HTML DOM Anchor hostname Property
Advertisements