I want to lay focus on changing content on my page. I want to use aria-live for this but I don't understand why it is not working. To figure it out I narrowed it out to a span:
<span class="message" aria-live="polite">Text 1</span>
And a line of jQuery that I run to change the text:
$('.message').text('Text 2');
The above line is called after a loading bar is at 100%. Full code:
/* @ -- Progressbar */
var timerCount = 0;
var lastCount = false;
var waitingTime = 10000; //ms
var waitingDevide = 100 / waitingTime;
function loadCalc() {
if (timerCount <= waitingTime) {
if (timerCount !== 0) {
/* @ ---- If not first call */
var currentPercentage = Math.round(timerCount * waitingDevide);
$('.waiting-progressbar-bar').css({width: currentPercentage + "%"});
$('.waiting-progressbar').attr('aria-valuenow', currentPercentage);
if (currentPercentage === 100) {
/* @ ------ When loading is done */
finishedLoading();
}
}
if (timerCount < waitingTime - 1000) {
/* @ ---- Create Random Time for Realistic loader */
var randomInterval = Math.floor(Math.random() * 11) * 100;
/* @ ---- Call Function After Random Time */
setTimeout(loadCalc, randomInterval);
/* @ ---- Add Random Number to Counter */
timerCount = timerCount + randomInterval;
} else if (timerCount !== waitingTime) {
var lastStep = waitingTime - timerCount;
timerCount = timerCount + lastStep;
setTimeout(loadCalc, lastStep);
}
}
}
loadCalc();
function finishedLoading(){
$('.message').text('Text 2');
}
I made a jsFiddle of the above code: https://jsfiddle.net/studiovds/czdug5yn/14/show
Running this with my OSX Voiceover screen reader on doesn't read the changed content aloud?