How to get all event handlers for an element with javascript ?
for getting event handlers for any element i can use this code
var events =$._data($("#btn").get(0), "events")["click"];
but this code only returns the events which defined as following :
$("#btn").on("click", function(){
alert(0)
});
$("#btn").on("click", function(){
alert(1)
});
but this line of code
var events =$._data($("#btn").get(0), "events")["click"];
does not return the events which defined like below :
$("body").on("click", "#btn", function(){
alert(2)
});
#btn, but ondocument, and the event only gets there because the event bubbles up to the document level.