Element: ariaPressed property

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.

The ariaPressed property of the Element interface reflects the value of the aria-pressed attribute, which indicates the current "pressed" state of toggle buttons.

Note: Where possible use an HTML element with type="button" or the

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
Save
js
let el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
console.log(el.ariaPressed); // "true"

Specifications

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

Browser compatibility

See also