Element: ariaSelected プロパティ

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.

ariaSelectedElement インターフェイスのプロパティで、aria-selected (en-US) 属性の値を反映し、選択状態を持つ要素の現在の "selected" 状態を示します。

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

"true"

この項目は選択されています。

"false"

この項目は選択されていません。

"undefined"

この項目は選択できません。

この例では、ID が tab-id の要素の aria-selected 属性は "true" に設定されています。ariaSelectedを使用して値を "false" に更新します。

html
<button role="tab" aria-selected="true" aria-controls="tabpanel-id" id="tab-id">
  Tab label
</button>
js
let el = document.getElementById("tab-id");
console.log(el.ariaSelected); // true
el.ariaSelected = "false";
console.log(el.ariaSelected); // false

仕様書

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

ブラウザーの互換性

BCD tables only load in the browser

関連情報