jQuery 1.0.2

2019-06-03 18:50:05于海丽

            if (!element.events)
                element.events = {};

            // Get the current list of functions bound to this event
            var handlers = element.events[type];

            // If it hasn't been initialized yet
            if (!handlers) {
                // Init the event handler queue
                handlers = element.events[type] = {};

                // Remember an existing handler, if it's already there
                if (element["on" + type])
                    handlers[0] = element["on" + type];
            }

            // Add the function to the element's handler list
            handlers[handler.guid] = handler;

            // And bind the global event handler to the element
            element["on" + type] = this.handle;

            // Remember the function in a global list (for triggering)
            if (!this.global[type])
                this.global[type] = [];
            this.global[type].push( element );
        },

        guid: 1,
        global: {},

        // Detach an event or set of events from an element