I have a page where some event listeners are attached to input boxes and select boxes. Is there a way to find out which event listeners are observing a particular DOM node a
I am trying to do that in jQuery 2.1, and with the "$().click() -> $(element).data("events").click;
" method it doesn't work.
I realized that only the $._data() functions works in my case :
$(document).ready(function(){
var node = $('body');
// Bind 3 events to body click
node.click(function(e) { alert('hello'); })
.click(function(e) { alert('bye'); })
.click(fun_1);
// Inspect the events of body
var events = $._data(node[0], "events").click;
var ev1 = events[0].handler // -> function(e) { alert('hello')
var ev2 = events[1].handler // -> function(e) { alert('bye')
var ev3 = events[2].handler // -> function fun_1()
$('body')
.append(' Event1 = ' + eval(ev1).toString() + '
')
.append(' Event2 = ' + eval(ev2).toString() + '
')
.append(' Event3 = ' + eval(ev3).toString() + '
');
});
function fun_1() {
var txt = 'text del missatge';
alert(txt);
}