HTML DOM selection.type property
The type property returns a String which describes the type of current selection. This is a read only property.
Return Value: String describing type of the selection. Possible return values are:
- None: No selection has currently been made.
- Caret: Only Clicked but not selected. The selection is collapsed, the caret is placed on some text, but no range has been selected.
- Range: Some range on which the text has been selected.
In this example, getSelection() method is used to get the selected text and type property is used to get the type of selection.
In console, types of selections can be seen on every change of selection.
- Google Chrome
- Internet Explorer