'watching' an element for any change within it
I recently ran into a situation where I had to modify a site that relied on an incredibly obfuscated and impossible to understand javascript file. I had to add in some elements after everything was populated with some function I didn't get, so I had to wait until a specific element was populated to do anything. Turns out the DOMNodeInserted event is what I needed:var title = $("b.facility"); var title = $('#title');//the element I want to monitor title.bind('DOMNodeInserted', function(e) { alert('element now contains: ' + $(e.target).html()); });
Pretty simple, but took me forever to figure out...