-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
53 lines (37 loc) · 1.6 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
---
title: "Element: ariaPressed property"
short-title: ariaPressed
slug: Web/API/Element/ariaPressed
page-type: web-api-instance-property
browser-compat: api.Element.ariaPressed
---
{{DefaultAPISidebar("DOM")}}
The **`ariaPressed`** property of the {{domxref("Element")}} interface reflects the value of the [`aria-pressed`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed) attribute, which indicates the current "pressed" state of toggle buttons.
> **Note:** Where possible use an HTML {{htmlelement("input")}} element with `type="button"` or the {{htmlelement("button")}} element as these have built in semantics and do not require ARIA attributes.
## Value
A string with one of the following values:
- `"true"`
- : The element is pressed.
- `"false"`
- : The element supports being pressed but is not currently pressed.
- `"mixed"`
- : Indicates a mixed mode value for a tri-state toggle button.
- `"undefined"`
- : The element does not support being pressed.
## Examples
In this example the `aria-pressed` attribute on the element with an ID of `saveChanges` is set to "false" indicating that this input is currently not pressed. Using `ariaPressed` we update the value to "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"
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [ARIA: button role](/en-US/docs/Web/Accessibility/ARIA/Roles/button_role)