Automatically Invoke a jQuery Plugin on a Dynamically-Created Element
You can use 'DOMNodeInserted' which is not a jQuery event.
$(document).bind('DOMNodeInserted', function(event) {
//write your stuff here to check if desired element was inserted or not.
alert('inserted ' + event.target.nodeName + // new node
' in ' + event.relatedNode.nodeName); // parent
});
Maybe something like this?
HTML
<a id="trigger-a" href="javascript:void(0);">Create a new div</a>
<div class="cont"></div>
JS
$("#trigger-a").click(function () {
var $div = $('<div>', {class: 'target', text: 'text'});
$('.cont').append($div);
$div.trigger('divCreate');
});
$('.cont').on('divCreate', 'div.target', function () {
$(this).append('added by event')
});
http://jsfiddle.net/Q2UYC/
Triggering custom event let you bind event handler later.