Document: selectionchange event

The selectionchange event of the Selection API is fired when the current text selection on a document is changed.

Bubbles No
Cancelable No
Interface Event
Event handler property onselectionchange

Examples

// addEventListener version
document.addEventListener('selectionchange', () => {
  console.log(document.getSelection());
});

// onselectionchange version
document.onselectionchange = () => {
  console.log(document.getSelection());
};

Specifications

Specification
Selection API
# selectionchange-event

Browser compatibility

BCD tables only load in the browser

See also