Selection API Demo

The Selection API provides methods to programmatically select text, get the current selection, and manipulate selected ranges within a document.

Selection API: checking...

API Support

Text Selection Monitor

Select any text in the paragraph below:

The Selection API is a powerful browser feature that allows JavaScript to programmatically interact with user text selections. It provides methods to get the currently selected text, create new selections, modify existing selections, and respond to selection changes. This API is essential for building rich text editors, annotation tools, and other interactive text-based applications. Try selecting different parts of this text to see the API in action!
Selected Text
-
Character Count
0
Range Count
0
Selection Type
None
Is Collapsed
-
Anchor/Focus Offset
-, -

Programmatic Selection

Select text programmatically by character position:

ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789

Word Selection

Click a word to select it in the text:

JavaScript provides powerful APIs for working with text selections in the browser. The Selection and Range objects give developers fine-grained control over selected content.

Selection Manipulation

Select text below, then apply actions:

This is an editable area where you can select text and apply transformations. Try selecting some text and clicking the buttons below to see the Selection API in action. You can also type and edit the content directly.

Find and Select

Find and select text matches:

The quick brown fox jumps over the lazy dog. The fox was very quick indeed. A quick movement of the enemy will jeopardize five gunboats. The five boxing wizards jump quickly.

Event Log

Selection events will appear here...