DOM
Element 接口的 ariaLabel 属性反射 aria-label 属性的值。该属性用于定义标记当前元素的字符串值。
值
字符串或 null。
示例
在本示例中,ID 为 close-button 的元素上的 aria-label 属性被设置为“关闭”。通过使用 ariaLabel,我们将该值更新为“关闭对话框”。
<button aria-label="关闭" id="close-button">X</button>
let el = document.getElementById("close-button");
console.log(el.ariaLabel); // “关闭”
el.ariaLabel = "关闭对话框";
console.log(el.ariaLabel); // “关闭对话框”
规范
浏览器兼容性
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
