Element: ariaLevel 属性

Baseline 2023
新推出

自 ⁨2023 年 10 月⁩ 以来,此功能已在最新设备和浏览器版本中得到支持。此功能可能无法在旧设备或浏览器上运行。

Element 接口的 ariaLevel 属性反映了 aria-level 属性的值,该属性定义了元素在结构中的层级。

注意: 尽可能使用 HTML 的 h1 或其他正确的标题级别,因为它们具有内置的语义,不需要 ARIA 属性。

包含整数的字符串。

示例

在此示例中,ID 为 main-heading 的元素上的 aria-level 属性设置为 "1"。使用 ariaLevel,我们将值更新为 "2"。

html
<div role="heading" id="main-heading" aria-level="1">
  This is a main page heading
</div>
js
let el = document.getElementById("main-heading");
console.log(el.ariaLevel); // "1"
el.ariaLevel = "2";
console.log(el.ariaLevel); // "2"

规范

规范
无障碍富互联网应用程序 (WAI-ARIA)
# dom-ariamixin-arialevel

浏览器兼容性

另见