Javascript: Is there a way to tell when a div has been added to an element? -
Say that I have third-party Twitter widgets on a page that will keep updating while making a new tweet. Is there a way to find out that when has a new device added to this widget? Is there an event or one I can hook on (probably widgets on the Parent Diva)?
If not, how do I do this? Perhaps the AJAX call is making the hook widget? How do I do that? It seems that firebug is doing this, but I can not tell how.
Again using any modern browser, you can use DOM mutation to listen to node changes. You can use the events. You are probably seeking from the details of your question. If you want you can use a awesome setTimeout (hack), but it is better to wait for the events of the spin around waiting for something to happen in general.
Here are some example codes because I'm bored:
var widget = document.getElementById ('mywidget'); Widget.addEventListener ('DomaineInsted', function (e) {if (e.target.nodeName! == 'DIV' returns; // returns some other code}, false);
Comments
Post a Comment