Element: ariaPressed プロパティ

Baseline 2023
Newly available

Since October 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

ariaPressedElement インターフェイスのプロパティで、トグルボタンの現在の押下状態を示す aria-pressed 属性の値を反映します。

メモ: 可能であれば、HTML の <input> 要素に type="button" を使用するか、<button> 要素を使用すると、意味づけが組み込まれており、ARIA 属性を持つ必要がありません。

以下のいずれかの値を持つ文字列です。

"true"

この要素は押下状態にあります。

"false"

この要素は押されることに対応していますが、現在は押下状態にありません。

"mixed"

3 状態トグルボタンの混在モード値を示します。

"undefined"

この要素は押下状態に対応していません。

この例では、saveChanges という ID を持つ要素の aria-pressed 属性は "false" に設定されており、この入力は現在押されていないことを示しています。ariaPressed を使用して、値を "true" に更新します。

html
<div id="saveChanges" tabindex="0" role="button" aria-pressed="false">Save</div>
js
let el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
console.log(el.ariaPressed); // "true"

仕様書

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# dom-ariamixin-ariapressed

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
ariaPressed

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報