web api instance property
HTMLAnchorElement: text property
The text property of the HTMLAnchorElement represents the text inside the element.
This property represents the same information as textContent.
Value
A string.
Example
<a id="exampleLink" href="https://example.com">Example Link</a>
<p class="text"></p>
#exampleLink {
font-size: 1.5rem;
}
const anchorElement = document.getElementById("exampleLink");
const pTag = document.querySelector(".text");
pTag.textContent = `Text property: ${anchorElement.text}`;
Result
Interactive exampleOpen the canonical MDN source to run this embedded demo.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.