HTML onselectionchange Event Attribute
Description
The onselectionchange event attribute runs a script when the text selection changes. Set on the document (document.onselectionchange), it fires whenever the selection anywhere in the page changes, including when the caret moves; read the selection with document.getSelection().
It can also be used on <input> and <textarea> elements, where it fires when the selection inside the field changes; use the element's selectionStart and selectionEnd properties to read it. The event is not cancelable and does not bubble when fired on the document.
Syntax
<element onselectionchange="script">
Values
- scriptThe name of the script to use when the event has been triggered.
Example
Browser Support
The following information will show you the current browser support for the HTML onselectionchange event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.
Desktop





Tablets & Mobile





