What is the closest thing to ActionScripts ADDED_TO_STAGE event. I need to know when a dynamically generated div has been added to another div
var myDiv = document.createElement("div");
$(someContainer).append(myDiv);
What is the closest thing to ActionScripts ADDED_TO_STAGE event. I need to know when a dynamically generated div has been added to another div
var myDiv = document.createElement("div");
$(someContainer).append(myDiv);
If you're using a function such as appendChild
to add static text to the DOM, that's a synchronous event. It will be added and rendered by the time your function returns.
If you're appending a child that depends on an external resource, you're looking for the onload
event. This works for the main document (window.onload = function() { ... }
), and according to What html tags support the onload/onerror javascript event attributes?, body, frame, frameset, iframe, img, link and script. (They apparently get their information from http://www.w3schools.com/jsref/event_onload.asp, which is not nearly as good as straight from the spec, but I couldn't find the details in there.)