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
define a function and do the job;
var funCalled = function(){ //your detailed actions }
and call it in different conditions!
if (some condition) { $(document).on('click','.selected-option',function(event){ funCalled() }) } else { $('.selected-option').click(function(event){ funCalled() }); }