HTMLTextAreaElement: selectionDirection property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The selectionDirection
property of the HTMLTextAreaElement
interface specifies the current direction of the selection. The possible values are "forward"
, "backward"
, and "none"
. The forward
value indicates the selection was performed in the start-to-end direction of the current locale, with backward
indicating the opposite direction. The none
value occurs if the direction is unknown. It can be used to both retrieve and change the direction of the <textarea>
s selected text.
Setting the selectionDirection
to a new value fires the selectchange
and select
events.
Value
A string; "forward"
, "backward"
, or "none"
.
Examples
const textarea = document.getElementById("text-box");
const end = textarea.selectionDirection;
Specifications
Specification |
---|
HTML Standard # dom-textarea/input-selectiondirection |
Browser compatibility
BCD tables only load in the browser
See also
<textarea>
HTMLTextAreaElement
HTMLTextAreaElement.selectionStart
HTMLTextAreaElement.selectionEnd
HTMLTextAreaElement.textLength
HTMLTextAreaElement.select()
HTMLTextAreaElement.setSelectionRange()
HTMLTextAreaElement.setRangeText()
HTMLInputElement.selectionDirection
Selection
::selection
pseudo-element