このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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月.

textHTMLAnchorElement のプロパティで、要素内のテキストを表します。 このプロパティは 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

ブラウザーの互換性

関連情報