Anchor text attribute
Definition and Usage
text
Sets or returns the link text content.
HTML elements are usually composed of element nodes and text nodes, for example, an <a> element with the text "Click me". If you want to get or set the text "Click me", please use this property.
Example
Example 1
Return the link text content:
var x = document.getElementById("myAnchor").text;
Example 2
Change the link text content (only for Internet Explorer 10+ and Firefox):
document.getElementById("myAnchor").text = "Click me to open the example link!";
Syntax
Return text attribute:
anchorObject.text
Set text attribute:
anchorObject.text = sometext
Attribute Value
Value | Description |
---|---|
sometext | Specifies the text content of the link. |
Technical Details
Return Value: | A string value representing the text content of the link. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |