JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>An item</li>
</ul>
<button id="foo">Click me</button>
<button id="bar">Me too</button>
JavaScript
$(function() {
var old = {
appendChild: Element.prototype.appendChild
};
var selector = "ul li.foo";
Element.prototype.appendChild = function(node) {
var retval = old.appendChild.apply(this, arguments);
if ($(node).is(selector)) {
alert("Matching element inserted!");
}
return retval;
};
$("button").on('click', function() {
$("ul").append("<li class=" + this.id + ">A dynamically added item</li>");
});
});