Very interesting question. You can get it as follows:
var refToFunc = $(".selector").data("events")["click"][0].handler;
Please note that we used [0]it because you have an array of handlers if you linked more than one handler. For other events, just change the name of the event.
, ( ):
$.fn.getEventHandlers = function(eventName){
var handlers = [];
this.each(function(){
$.each($(this).data("events")[eventName], function(i, elem){
handlers.push(elem.handler);
});
});
return handlers;
};
?:
$(".selector").getEventHandlers("click");
, .
:
var refToFunc = $(".selector").getEventHandlers("click")[0];
, .