According to the w3 documentation we can use the aria-live
attribute to tell a screen reader to read the text contents of a HTML element when it gets changed. However, in my case, i wont be updating any text and simply want a screen reader to announce the contents of a <span>
when it becomes visible under some condition (that is, by using jQuery's .show()
function)
here is a simplification of my HTML & JS:
<div class="toggleable_element" hidden>
<span aria-live="assertive">Text to be read out</span>
</div>
....
<script>
$("#toggleable_element").show();
</script>
Using aria-live like this wont trigger the screen reader from reading the text (i am using JAWS in this case).
Another suggestion is to add the attribute role="alert"
although this doesnt seem to trigger a screen reader announcement either.
Any suggestions on how to get the contents of the span to be read aloud?