Can the aria-live attribute of a given element itself be set dynamically with javascript?

StackOverflow https://stackoverflow.com/questions/10637231

  •  09-06-2021
  •  | 
  •  

Frage

More specifically, if it is set with javascript will the screen reader/AT software still pick up the attribute and correctly announce any changes within the element to the user even though it was not present on page load?

If anyone has any experience of this I would appreciate any details you have.

Here's an example of what I want to achieve...

Before the javascript call:

<body>

Set a property with jQuery (or whatever)...

$('body').attr('aria-live', 'polite');

After call:

<body aria-live="polite">

Thanks in advance to anyone who has anything to add.

War es hilfreich?

Lösung

Yes, depending on the context, the reader will pick up changes to attributes and announce updates to the users. This allows readers to be useful as chat or email clients, and is the purpose of the aria-live attribute. One use case is the "aria-selected" attribute, which can be assigned to navigation elements and can be used to indicate the "active" navigation item.

Mozilla Developer Network ARIA live regions

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top