元素: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 |
瀏覽器相容性
載入中…