JSFiddle - React, Tailwind, and code Playground

JavaScript

(function($) {
    var origAppend = $.fn.append;
    
    $.fn.append = function () {
        return origAppend.apply(this, arguments).trigger("append");
    };
    
    var origRemove = $.fn.remove;
    
    $.fn.remove = function () {
        if(arguments.length){
            return origRemove.apply(this, arguments).trigger("remove");
        }else{
            var $parent = this.parent();
            console.log(this)
            origRemove.apply(this, arguments);
            $parent.trigger('remove');
            return this
        }
    };
})(jQuery);

$('body').on({
    'remove' : function(){alert('removed')},
    'append' : function(){alert('appended')}
})

$('body').append('<div/>');
$('div').remove()