JSFiddle - React, Tailwind, and code Playground
by rvrjp7
HTML
<!DOCTYPE html>
<html>
<body>
<div id="div1" aria-live="polite">
<p id="p1">This is a paragraph.</p>
<p id="p2">This is another paragraph.</p>
</div>
<p>Click the button to start adding new div".</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var i=1;
var s= setInterval(function(){
var para = document.createElement("div");
var node = document.createTextNode("This is new div. with aria live attribute"+i);
i++;
para.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(para);
if(i==5){
clearInterval(s);
}}, 1000);
}
</script>
</body>
</html>