JSFiddle - React, Tailwind, and code Playground
by Andrew Holloway
HTML
<button id="button">
Change the Aria
</button>
<div class="aria-container" id="a11y" aria-live="polite"></div>
JavaScript
document.getElementById('button').addEventListener('click', function() {
handleAria('test text');
});
var container = document.getElementById('a11y');
var timeout;
function handleAria(withText) {
container.innerHTML = withText;
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
container.innerHTML = '';
}, 5000);
}