Selection: removeRange() Methode
Baseline
2023
Newly available
Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Die Selection.removeRange()
Methode entfernt einen Bereich aus einer Auswahl.
Syntax
js
removeRange(range)
Parameter
range
-
Ein Bereichsobjekt, das aus der Auswahl entfernt wird.
Rückgabewert
Keiner (undefined
).
Beispiele
js
/* 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));
}
}
Spezifikationen
Specification |
---|
Selection API> # dom-selection-removerange> |
Browser-Kompatibilität
Loading…
Siehe auch
Selection
, das Interface, zu dem es gehört.