Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
メモ: この API は Web Workers では 使用できません。(WorkerNavigator 経由では公開されていません)
Selection API は、開発者がドキュメントのユーザーに選択されている部分にアクセスしたり操作したりできるようにします。
Window.getSelection() および Document.getSelection() メソッドは、ドキュメントのユーザーに選択されている部分を表す Selection オブジェクトを返します。Selection オブジェクトは、以下を行うメソッドを提供します。
Selection API は、Document で発火する 2 種類のイベントも提供します。
ドキュメントのユーザーによって選択されている部分、またはキャレットの現在の位置を表すインターフェイスです。
Document.getSelection()現在の選択範囲、またはキャレットの現在の位置を表す Selection オブジェクトを返すメソッドです。
Window.getSelection()現在の選択範囲、またはキャレットの現在の位置を表す Selection オブジェクトを返すメソッドです。
Document.selectionchange現在の選択範囲が変更されたとき発火するイベントです。
Node.selectstartユーザーが新しく選択を開始したとき発火するイベントです。
| Selection API # selection-interface |
This page was last modified on 2024年7月28日 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.