Element: ariaLabel 属性
Element 接口的 ariaLabel 属性反映了 aria-label 属性的值。该属性定义了用于标记当前元素的字符串值。
值
字符串或 null。
示例
在此示例中,ID 为 close-button 的元素的 aria-label 属性设置为“Close”。使用 ariaLabel,我们将该值更新为“Close dialog”。
html
<button aria-label="Close" id="close-button">X</button>
js
let el = document.getElementById("close-button");
console.log(el.ariaLabel); // "Close"
el.ariaLabel = "Close dialog";
console.log(el.ariaLabel); // "Close dialog"
规范
| 规范 |
|---|
| 无障碍富互联网应用程序 (WAI-ARIA) # dom-ariamixin-arialabel |
浏览器兼容性
加载中…