docs.rodeo

MDN Web Docs mirror

Selection API

{{DefaultAPISidebar("Selection API")}} 

[!NOTE] This API is not available in Web Workers (not exposed via {{domxref("WorkerNavigator")}} ).

The Selection API enables developers to access and manipulate the portion of a document selected by the user.

The {{domxref("Window/getSelection()", "Window.getSelection()")}}  and {{domxref("Document/getSelection()", "Document.getSelection()")}}  methods return a {{domxref("Selection")}}  object representing the portion of the document selected by the user. A Selection object provides methods to:

The Selection API also provides two events, both firing on {{domxref("Document")}} :

Interfaces

Specifications

{{Specifications}} 

In this article

View on MDN