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