I’ve done quite a bit of searching for a solution to this problem but so far haven’t found one that works cross browser.
What I need is a raw javascript function which will take an element and run a callback once the innerHTML has successfully been inserted into the dom.
e.g.
var element = document.getElementById('example');
element.innerHTML = newhtml;
waitUntilReady(element, function(){
//do stuff here...
});
So just to summarize, I need to be able to check the contents of the element and fire a callback when innerHTML has completed.
Thanks in advance for any help.
There is no need for such a function. Assigning to
innerHTMLwill do so immediately before continuing to run any scripts.If you really need to delay execution (say to allow the browser to redraw), use
setTimeoutwith a delay of1(or other short interval).