JSFiddle - React, Tailwind, and code Playground
HTML
<a class="div" href=#>div</a>
<a class="span" href=#>div, span</a>
<a class="blank" href=#>Blank?</a>
JavaScript
(function($){
(function(){
// Store a reference to the original add method.
var originalAddMethod = jQuery.fn.add;
// Define overriding method.
jQuery.fn.add = function( selector, context ){
// Log the fact that we are calling our override.
console.log( "Override method" );
// Execute the original method.
var ret = originalAddMethod.apply( this, arguments );
if (this.selector && selector && typeof this.selector === "string" && typeof selector === "string") {
ret.selector = this.selector + ", " + selector;
}
return ret;
}
})();
$.fn.getSelector = function(){
return(this.selector);
}
})(jQuery)
$('.div').click(function(){
alert($('div').getSelector());
});
$('.span').click(function(){
alert($('div, span').getSelector());
});
$('.blank').click(function(){
//alert($('div').find('span').selector);
alert($('div').add('span').getSelector());
});