You can manage your custom events only by creating event handling yourself. For example, in your case I could assume you want to fire some event each time you call appendChild DOM function. The following way could be a possible solution (if we talk about pure JavaScript, but it gives a right way to understand the concept):
function() {
// of course it could be done better here to remove from array but it's not the topic
function removeItem( arr, item) {
for(var i = 0, s = arr.length; i < s; i++){
if(arr[i]==item){
arr.splice( i, 1);
break;
}
}
};
// our custom event object
var MyDomEvents = {
events = {},
on : function( evt, handler) {
this.events[evt] = this.events[evt] || [];
this.events[evt].push( handler);
},
un : function( evt, handler) {
if (this.events[evt]) {
removeItem( this.events[evt], handler);
}
},
fireEvent : function() {
var evt = arguments[0], args = [];
for (var i = 1, s = arguments.length; i < s; i++) {
args.push( arguments[i]);
}
if (this.events[evt]) {
for (var i = 0, s = this.events[evt].length; i < s; i++) {
if (this.events[evt][i] &&
this.events[evt][i].apply( this, args) == false) {
return ; // stop an event if it returns false
}
}
}
}
};
// very dirty but maybe it's something you are looking for
var orig = HTMLElement.prototype.appendChild;
HTMLElement.prototype.appendChild = function( node) {
orig.call( this, node);
MyDomEvents.fireEvent( 'append', this, node);
}
// usage:
MyDomEvents.on( 'append', function( parent, child) {
// handle append event
});
}();
Of course, something similar could be done on jQuery's "append" method or you can use your own "append" method everywhere in your code to not override the DOM's native one (which is really not a good practice, and not all browsers could let you do that). I'm just showing a main concept of how that could be done.
Please, note, I didn't test the code above, I had written it just to show an idea.