Element: thuộc tính ariaReadOnly
Baseline
2023
Newly available
Since October 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Thuộc tính ariaReadOnly của giao diện Element phản chiếu giá trị của thuộc tính aria-readonly, cho biết phần tử không thể chỉnh sửa, nhưng vẫn có thể hoạt động khác.
Note:
Khi có thể, hãy sử dụng phần tử HTML <input> với type="text" hoặc <textarea> vì chúng có ngữ nghĩa tích hợp sẵn và không yêu cầu thuộc tính ARIA.
Giá trị
Một chuỗi với một trong các giá trị sau:
Ví dụ
Trong ví dụ này, thuộc tính aria-readonly trên phần tử có ID txtBoxInput được đặt thành "true" cho biết đầu vào này hiện chỉ ở chế độ đọc. Sử dụng ariaReadOnly chúng ta cập nhật giá trị thành "false".
html
<div id="txtboxMultilineLabel">Enter the tags for the article</div>
<div
role="textbox"
id="txtBoxInput"
contenteditable="true"
aria-multiline="true"
aria-labelledby="txtboxMultilineLabel"
aria-readonly="true"></div>
js
let el = document.getElementById("txtBoxInput");
console.log(el.ariaReadOnly); // "true"
el.ariaReadOnly = "false";
console.log(el.ariaReadOnly); // "false"
Đặc tả kỹ thuật
| Specification |
|---|
| Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-ariareadonly> |