1

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);
The_asMan
  • 6,364
  • 4
  • 23
  • 34

1 Answers1

1

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.)

Community
  • 1
  • 1
Scott Mermelstein
  • 15,174
  • 4
  • 48
  • 76