JSFiddle - React, Tailwind, and code Playground
HTML
Click on div 2 to affect div 1
<div id="div1">div 1</div>
<div id="div2">div 2</div>
CSS
#div1 { color: blue; }
#div2 { color: red; }
JavaScript
$.fn.observe = function(eventName, callback) {
return this.each(function(){
var el = this;
$(document).on(eventName, function(){
callback.apply(el, arguments);
})
});
}
$('#div2').on('click', function(e) {
$(this).trigger('custom');
});
$('#div1').observe('custom', function(e) {
$(this).css('color', 'green');
});