HTMLAnchorElement: text プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
text は HTMLAnchorElement のプロパティで、要素内のテキストを表します。 このプロパティは Node.textContent と同じ情報を表します。
値
文字列です。
例
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}`; 結果
仕様書
| Specification |
|---|
| HTML> # dom-a-text> |
ブラウザーの互換性
関連情報
HTMLScriptElement.textプロパティHTMLOptionElement.textプロパティ