After element is created event?

After element is created event?

Imagine an element with a specific selector getting created and then once the element exists and the selector is applied, all of the behaviors are applied (events, styles and plugin methods).

Here is an example:

$.create = function(elementTagName) {
   return $(document.createElement(elementTagName));
}

$.create("div").addClass("myDiv");

now what I would like is a method that would apply behaviors after the element exists in DOM.

$.onElementCreation(".myDiv",function(){//apply behaviors here});

This would be similar to the live event where a function is applied to the specified event of all selectors even if they do not exist yet. The only difference is that the event is not the typical peripheral driven event (mousemove, keyup,etc) but would be fired once that element exists in DOM.


Any thoughts?