HTMLTextAreaElement: selectionchange event

Baseline 2024
Newly available

Since September 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The selectionchange event of the Selection API is fired when the text selection within a <textarea> element is changed in either extent or direction, whether the selection is a caret or a range of characters.

For general information about this event, see HTMLInputElement: selectionchange event.

Syntax

Use the event name in addEventListener():

js
addEventListener("selectionchange", (event) => { })

Alternatively, assign to the event handler property of the interface:

js
onselectionchange = (event) => { }

Event type

A generic Event.

Specifications

Specification
Selection API
# selectionchange-event
Selection API
# dom-globaleventhandlers-onselectionchange

Browser compatibility