Anchor id Property
Description
The id property sets or returns the value of the id attribute of a link.
The id attribute specifies the id of an anchor, and can be used to create a bookmark inside a document.
Browser Support
Property | |||||
---|---|---|---|---|---|
id | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the id property:
anchorObject.id
Set the id property:
anchorObject.id = id
Property Values
Value | Description |
---|---|
id | Specifies the id of a link |
Technical Details
Return Value: | A String, representing the id of the link |
---|
More Examples
Example
Change the id of a link:
document.getElementById("myAnchor").id = "newid";
Try it Yourself »
Example
A demonstration of how to change the id of an anchor to create a bookmark inside a document:
document.getElementById("typo").id = "C6";
Try it Yourself »
Related Pages
HTML reference: HTML id attribute
❮ Anchor Object