元素:ariaReadOnly 属性
Element 接口的 ariaReadOnly 属性反映了 aria-readonly 属性的值,该属性指示该元素不可编辑,但仍可操作。
注意: 尽可能使用具有 type="text" 的 HTML <input> 元素或 <textarea> 元素,因为它们具有内置的语义,不需要 ARIA 属性。
值
一个字符串,其值可能为以下之一:
示例
在此示例中,ID 为 txtBoxInput 的元素的 aria-readonly 属性设置为“true”,表示此输入当前为只读。使用 ariaReadOnly,我们将值更新为“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"
规范
| 规范 |
|---|
| 无障碍富互联网应用程序 (WAI-ARIA) # dom-ariamixin-ariareadonly |
浏览器兼容性
加载中…