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 January 2020.
Thuộc tính selectionDirection của giao diện HTMLTextAreaElement chỉ định hướng hiện tại của vùng chọn. Các giá trị có thể là "forward", "backward" và "none". Giá trị forward cho biết vùng chọn được tạo theo hướng từ đầu đến cuối của ngôn ngữ hiện tại, còn backward cho biết hướng ngược lại. Giá trị none xuất hiện nếu hướng không xác định. Thuộc tính này có thể được dùng để vừa lấy vừa thay đổi hướng của văn bản được chọn trong <textarea>.
Đặt selectionDirection thành giá trị mới sẽ kích hoạt các sự kiện selectionchange và select.
Giá trị
Một chuỗi; "forward", "backward", hoặc "none".
Ví dụ
js
const textarea = document.getElementById("text-box");
const end = textarea.selectionDirection;
Đặc tả kỹ thuật
| Thông số kỹ thuật |
|---|
| HTML> # dom-textarea/input-selectiondirection> |
Tương thích trình duyệt
Xem thêm
<textarea>HTMLTextAreaElementHTMLTextAreaElement.selectionStartHTMLTextAreaElement.selectionEndHTMLTextAreaElement.textLengthHTMLTextAreaElement.select()HTMLTextAreaElement.setSelectionRange()HTMLTextAreaElement.setRangeText()HTMLInputElement.selectionDirectionSelection- Pseudo-element
::selection