-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
61 lines (45 loc) · 1.73 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "Element: ariaChecked property"
short-title: ariaChecked
slug: Web/API/Element/ariaChecked
page-type: web-api-instance-property
browser-compat: api.Element.ariaChecked
---
{{APIRef("DOM")}}
The **`ariaChecked`** property of the {{domxref("Element")}} interface reflects the value of the [`aria-checked`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked) attribute, which indicates the current "checked" state of checkboxes, radio buttons, and other widgets that have a checked state.
> [!NOTE]
> Where possible use an HTML {{htmlelement("input")}} element with `type="checkbox"` as this element has built in semantics and does not require ARIA attributes.
## Value
A string with one of the following values:
- `"true"`
- : The element is checked.
- `"mixed"`
- : Indicates a mixed mode value for a tri-state checkbox or menuitemcheckbox.
- `"false"`
- : The element supports being checked but is not currently checked.
- `"undefined"`
- : The element does not support being checked.
## Examples
In this example the `aria-checked` attribute on the element with an ID of `checkBoxInput` is set to "false" indicating that this input is currently unchecked. Using `ariaChecked` we update the value to "true".
```html
<span
role="checkbox"
id="checkBoxInput"
aria-checked="false"
tabindex="0"
aria-labelledby="chk1-label">
</span>
<label id="chk1-label">Remember my preferences</label>
```
```js
let el = document.getElementById("checkBoxInput");
console.log(el.ariaChecked); // "false"
el.ariaChecked = "true";
console.log(el.ariaChecked); // "true"
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [ARIA: checkbox role](/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox_role)