Element:ariaLabel 属性
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.
Element
接口的 ariaLabel
属性反射 aria-label
属性的值。该属性用于定义标记当前元素的字符串值。
值
字符串或 null
。
示例
在本示例中,ID 为 close-button
的元素上的 aria-label
属性被设置为“关闭”。通过使用 ariaLabel
,我们将该值更新为“关闭对话框”。
html
<button aria-label="关闭" id="close-button">X</button>
js
let el = document.getElementById("close-button");
console.log(el.ariaLabel); // “关闭”
el.ariaLabel = "关闭对话框";
console.log(el.ariaLabel); // “关闭对话框”
规范
Specification |
---|
Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-arialabel> |
浏览器兼容性
Loading…