The ariaSelected
property of the Element
interface reflects the value of the aria-selected
attribute, which indicates the current "selected" state of elements that have a selected state.
The ariaSelected
property of the Element
interface reflects the value of the aria-selected
attribute, which indicates the current "selected" state of elements that have a selected state.
A string with one of the following values:
"true"
The item is selected.
"false"
The item is not selected.
"undefined"
The item is not
In this example the aria-selected
attribute on the element with an ID of tab-id
is set to "true". Using ariaSelected
we update the value to "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
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
ariaSelected |
81 | 81 | 119 | No | 68 | 12.1 | 81 | 81 | 119 | 58 | 12.2 | 13.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaSelected