Selection: type-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
Die type
schreibgeschützte Eigenschaft des
Selection
Interfaces gibt einen String zurück, der den
Typ der aktuellen Auswahl beschreibt.
Wert
Beispiele
In diesem Beispiel wird der Ereignishandler jedes Mal ausgelöst, wenn eine neue Auswahl erfolgt.
console.log(selection.type)
gibt Caret
oder
Range
zurück, abhängig davon, ob der Cursor an einem einzelnen Punkt im
Text platziert ist oder ein Bereich ausgewählt wurde.
let selection;
document.onselectionchange = () => {
console.log("New selection made");
selection = document.getSelection();
console.log(selection.type);
};
Spezifikationen
Specification |
---|
Selection API # dom-selection-type |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support