JSFiddle - React, Tailwind, and code Playground

HTML

<div id = "content" >
  <div class = "child" >Hello !! </div>
</div>

JavaScript

$.fn.addClick = function(fn) {
    var selector = this.selector;
    this.click(function(event) {
        fn(event, selector);
    });
};

// should log #content .child on console
$("#content .child").addClick(function(e, selector) {
    console.log(selector);
});

// binding a click to the same element, but with a different selector
// this one should log div.child on console
// but we should still see the previous selector.
$("div.child").addClick(function(e, selector) {
    console.log(selector);
});