Element: ariaLabel 屬性

Baseline 2023
新推出

自 ⁨2023 年 10 月⁩ 以來,此功能已在最新裝置和瀏覽器版本中得到支援。此功能可能無法在舊裝置或瀏覽器上執行。

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

瀏覽器相容性