Web APIs

Selection API

Checking compatibility...

Access and manipulate the portion of a document selected by the user. Perfect for text editors, highlighting tools, and custom selection behaviors.

Basic Selection Monitoring

Track what text users are highlighting on your page. This example shows how to detect when users select text and get information about their selection, such as the selected content and where the selection starts and ends.

=
=
=
=
=
=

Output

Click Run to see output...

Selection Manipulation

Create and modify text selections programmatically. This example demonstrates how to select specific content without user interaction, which is useful for highlighting important information or implementing 'Select All' functionality in text editors.

=
=
=
=
=
=

Output

Click Run to see output...