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 | Status | Comment |
---|---|---|
Selection API The definition of 'selectionchange' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser