Можно ли получить все обработчики, которые есть у определённого элемента?
Видел такой способ: $._data(element, 'events');
, но он не всегда работает: в коде ниже показывается только обработчик mousemove
$(document).on('click', 'img', function() {
console.log('clicked');
});
$('img').on('mousemove', function() {
console.log('mousemove');
});
function showHandlers(element) {
console.log($._data(element, 'events'));
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="http://lorempixel.com/400/200/">
<input type="button" value="Show handlers" onclick="showHandlers($('img')[0])">
Как получить все обработчики?