I have one code block which I want to invoke in different scenarios when a click is triggered, depending on whether the event is direct or is delegated.
But on changing
var testfunction = function(currentObj){ // your code here } if (some condition) { $(document).on('click','.selected-option',function(event){ testfunction($(this)); }); } else { $('.selected-option').click(function(event){ testfunction($(this)); }); }