Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
HTMLTitleElement インターフェイスは文書の <title> が実装しています。この要素は HTMLElement インターフェイスのすべてのプロパティおよびメソッドを継承しています。
EventTarget Node Element HTMLElement HTMLTitleElement親である HTMLElement から継承したプロパティがあります。
HTMLTitleElement.text文字列で、文書の題名のテキストを表し、またテキスト部分のみを表します。例えば、この例を考えてみてください。
ご覧の通り、span タグとその内容はスキップされています。
固有のメソッドはありません。親である HTMLElement から継承したメソッドがあります。
document.title と document.querySelector('title') を混同しないでください。
前者は文書の題名の内側のテキスト値を設定したり取得したりするための単なるセッター/ゲッターメソッドで、後者は HTMLTitleElement オブジェクトです。ですから、document.title.text = "Hello world!"; のように書くことはできません。
代わりに、シンプルに document.title = "Hello world!"; と書くことができます。これは document.querySelector('title').text = "Hello world!"; と等価です。
| HTML # htmltitleelement |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2023年7月20日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.