The Selection.removeRange() method removes a range from a selection.
removeRange(range)rangeA range object that will be removed from the selection.
None (undefined).
/* Programmatically, more than one range can be selected.
* This will remove all ranges except the first. */
const s = window.getSelection();
if (s.rangeCount > 1) {
for (let i = 1; i < s.rangeCount; i++) {
s.removeRange(s.getRangeAt(i));
}
}Selection, the interface it belongs to.