Skip to content

Commit

Permalink
Document for HTMLAnchorElement.text (#31887)
Browse files Browse the repository at this point in the history
* document for HTMLAnchorElement.text

* example

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: skyclouds2001 <[email protected]>

* header fix

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: dawei-wang <[email protected]>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: Jean-Yves Perrier <[email protected]>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: Jean-Yves Perrier <[email protected]>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/htmlanchorelement/text/index.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: skyclouds2001 <[email protected]>
Co-authored-by: dawei-wang <[email protected]>
Co-authored-by: Jean-Yves Perrier <[email protected]>
  • Loading branch information
5 people authored Jan 26, 2024
1 parent 6da4cf5 commit b20bd35
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions files/en-us/web/api/htmlanchorelement/text/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: "HTMLAnchorElement: text property"
short-title: text
slug: Web/API/HTMLAnchorElement/text
page-type: web-api-instance-property
browser-compat: api.HTMLAnchorElement.text
---

{{ApiRef("HTML DOM")}}

The **`text`** property of the {{domxref("HTMLAnchorElement")}} represents the text inside the the element.
This property represents the same information as {{domxref("Node.textContent")}}.

## Value

A string.

## Example

```html
<a id="exampleLink" href="https://example.com">Example Link</a>
<p class="text"></p>
```

```css
#exampleLink {
font-size: 1.5rem;
}
```

```js
const anchorElement = document.getElementById("exampleLink");
const pTag = document.querySelector(".text");
pTag.textContent = `Text property: ${anchorElement.text}`;
```

### Result

{{EmbedLiveSample("Example",100,100)}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("HTMLScriptElement.text")}} property
- {{domxref("HTMLOptionElement.text")}} property

0 comments on commit b20bd35

Please sign in to comment.