JSFiddle - React, Tailwind, and code Playground

by jakie8

HTML

<button>Click</button>

JavaScript

(function (d, $) {
    "use strict";
    var _target = $.fn,
        replace = [
            "append",
            "appendTo",
            "prepend",
            "prependTo",
            "before",
            "insertBefore",
            "after",
            "insertAfter",
            "remove",
            "html",
            "replaceWith"
        ],
        _old = {},
        i;

    for (i = 0; i < replace.length; i++) {
        (function (method) {
            _old[method] = _target[method];
            _target[method] = function () {
                $(d).trigger(method);
                _old[method].apply(this, arguments);
            };
        })(replace[i]);
    }

}).call(this, document, jQuery);


$(document).on('click', 'button', function () {
    $('<span>text</span>').prependTo('body');
});

$(document).on('append', function(){
    console.log('Appended Shiet');
});
$(document).on('prependTo', function(){
    console.log('Prepended Shiet');
});

$(document).on('after', function(){
    console.log('After Shiet');
});