You can use the mutation event DOMNodeInserted, but keep in mind that they are outdated and not supported in all browsers.
A better solution would be to write a custom event, for example:
$('#container').bind('MyAddEvent', function(){
alert('Was added');
});
If you want the event to also apply to new elements, use on:
$('#container').on('MyAddEvent', '{selector}' ,function(){
alert('Was added');
});
<div> ( ajax-), trigger:
...
success: function(result){
$('#container').append(result)
...
...
$('#container').trigger('MyAddEvent');
}
div, DOM x divs:
function checkForChanges()
{
var newDivs = $('#container div').filter(function(){
return !$(this).data('old')
});
...
newDivs.data('old', true);
setTimeout(checkForChanges, 1000);
}
$(checkForChanges);