When creating and inserting DOM elements, it seems that the functions used for the task are returned before the elements are displayed on the page.
Before embedding elements, I set the display property of the div to "block", and after inserting the elements I set the property to "none", the problem is that the indicator does not appear on the page. It can be done? Where $ is an alias for document.getElementById.
$('loading').className="visible";
var container = document.getElementById('container');
for(var i=0; i< 50000; i++){
var para = document.createElement('p');
para.appendChild(document.createTextNode('Paragraph No. ' + i));
container.appendChild(para);
}
$('loading').className="hidden";
It seems that createElement and / or appendChild are running asynchronously, so I hide the indicator almost immediately?
source
share