ElementInternals: ariaPressed 屬性
ElementInternals 介面的 ariaPressed 屬性反映了 aria-pressed 屬性的值,該屬性指示切換按鈕當前的“按下”狀態。
注意:在 ElementInternals 上設定 ARIA 屬性允許為自定義元素定義預設語義。這些預設語義可能會被作者定義的屬性覆蓋,但可以確保在作者刪除或根本未新增這些屬性時,預設語義仍然保留。有關更多資訊,請參閱 Accessibility Object Model explainer。
值
一個字串,其值可能為以下之一:
"true"-
元素被按下。
"false"-
元素支援被按下,但當前未被按下。
"mixed"-
指示三態切換按鈕的混合模式值。
"undefined"-
元素不支援被按下。
示例
在此示例中,ariaPressed 的值為 "true"。
js
class CustomControl extends HTMLElement {
constructor() {
super();
this.internals_ = this.attachInternals();
this.internals_.ariaPressed = "true";
}
// …
}
規範
| 規範 |
|---|
| 無障礙富網際網路應用程式 (WAI-ARIA) # dom-ariamixin-ariapressed |
瀏覽器相容性
載入中…