JSFiddle - React, Tailwind, and code Playground
HTML
<div id="threat"></div>
<div id="cool"></div>
JavaScript
//@Author Karl-André Gagnon
$.hook = function(){
$.each(arguments, function(){
var fn = this
if(!$.fn['hooked'+fn]){
$.fn['hooked'+fn] = $.fn[fn];
$.fn[fn] = function(){
var r = $.fn['hooked'+fn].apply(this, arguments);
$(this).trigger(fn, arguments);
return r
}
}
})
}
$.hook('html');
$(document).on('html', '#threat, #cool, #not_cool',function(){
alert('B')
})
$('#threat, #cool').html('blue')
$('body').append('<div id="not_cool">')
$('#not_cool').html('L')