First of all, when binding jQuery events, all events are stored in $.cache using the $.data() method, and they can be obtained repeatedly using data('events'):
var $div = $('div.demo'), data = $div.data(); // Get all binding events: var events = data.events; // Except for the special binding events of the window object: var windowEvents = $(window).data('__events__' ; 🎜> The code is as follows:
var clickHandler = function(){ console.log('click test');
After 1.4.2, events[type] is an array, and the for...in loop will get all the methods extended on the array prototype, and then bind them to the DOM object. Solution Do not extend the array prototype and do not use the clone(true) method. hasOwnProperty check. Use each loop:
Copy code
The code is as follows:
var self = this; for ( var type in events ) {
jQuery.each(events[ type ],function(idx,evt) { jQuery.event.add( self, type, evt.handler, evt.data ; > The code is as follows:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn