Jquery.event Wrapper Event Object

Source: Internet
Author: User
Tags extend unique id wrapper

Jquery.event Wrapper Event Object


Due to the differences of native event objects in different browsers, most JS libraries/frames have been repaired and packaged for native event objects.

For example, stop event bubbling ie with cancelbubble, standard browser with stoppropagation.

Get event source object, ie with srcelement, standard browser with target and so on.

JQuery mainly uses Jquery.event class and JQuery.event.fix method to fix and package native event objects.

jquery.event = function (src) {
Allow instantiation without the ' new ' keyword
if (!this.preventdefault) {
return new jquery.event (SRC);
}

Event Object
if (src && src.type) {
This.originalevent = src;
This.type = Src.type;

Events bubbling up the document may have been marked as prevented
By a handler lower down the tree; reflect the correct value.
this.isdefaultprevented = (src.defaultprevented | | | src.returnvalue = = FALSE | |
Src.getpreventdefault && src.getpreventdefault ()? Returntrue:returnfalse;

Event type
} else {
This.type = src;
}

TimeStamp is buggy to some events on Firefox (#3843)
So we won ' t rely on the native value
This.timestamp = Jquery.now ();

Mark it as fixed
this[Jquery.expando] = true;
};

function Returnfalse () {
return false;
}
function Returntrue () {
return true;
}

Jquery.event is based on DOM3 Events as specified by the ECMAScript Language
Http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
JQuery.Event.prototype = {
Preventdefault:function () {
this.isdefaultprevented = Returntrue;

var e = this.originalevent;
if (!e) {
Return
}

If Preventdefault exists run it on the original event
if (E.preventdefault) {
E.preventdefault ();

Otherwise set the ReturnValue property of the original event to False (IE)
} else {
E.returnvalue = false;
}
},
Stoppropagation:function () {
this.ispropagationstopped = Returntrue;

var e = this.originalevent;
if (!e) {
Return
}
If stoppropagation exists run it on the original event
if (e.stoppropagation) {
E.stoppropagation ();
}
Otherwise set the Cancelbubble property of the original event to True (IE)
E.cancelbubble = true;
},
Stopimmediatepropagation:function () {
this.isimmediatepropagationstopped = Returntrue;
This.stoppropagation ();
},
Isdefaultprevented:returnfalse,
Ispropagationstopped:returnfalse,
Isimmediatepropagationstopped:returnfalse
};


JQuery Event handling (event handling)

Example one: Click on a specific selector

Clicking on the button with class "alert" will trigger the alarm.

Code:

$ (document). Ready (function () {
$ (' Button.alert '). Click (function () {
Alert (' Welcome to 61dh.com! ');
});
});
<button class= "alert" > Specific click </button> Demo: Specific clicks

2. Example two: Click event only occurs 1 times
When a link with id "Create-button" is clicked, a button is created after the link, but if the button already exists, it is no longer created.

Code:

$ (' #create-button '). Click (function () {
if ($ (' button.new '). Length <1) {//depending on the need here you can set ' length ' to a different value
$ (' <button class= ' new ' > button just created </button> '). InsertAfter (this);
}
});
<button id= "Create-button" > Create a Button </button> Demo: Create a button

3. Example three: The delegation and delivery of events

When a column in the list is clicked, the new column is added to the list. If you want the newly added column to have the same event control, we can use event delegation to pass the event-handling method to the new column.

Code:

$ (document). Ready (function () {
$ (' #list2 '). Click (Function (event) {//NOTE: Here is a parameter: event
var $newLi = $ (' <li class= "special" ><button> New button </button></li> ');
var $tgt = $ (event.target); Note: The target function is used here
if ($tgt. Is (' button ')) {
$tgt. Parent () after ($newLi);
}//here, the IS () function is used to determine the properties of the currently clicked element and, if it is the button, to trigger the event.
});
});

The Jquery.event class mainly did the following work

1, the Originalevent property is expanded, which temporarily saves the native event object.
2, fixes the TimeStamp, this property IE6/7/8 does not support, the other supports each browser The return value is also different.
3, block DOM element default behavior uniformly using Preventdefault
4, stop event bubbling unified use Stoppropagation
5, to achieve or expand the DOM3 event of several methods: Stopimmediatepropagation, isdefaultprevented, ispropagationstopped, isimmediatepropagationstopped

In addition, Jquery.event's writing style is also more unique. It creates an object using hidden new.

The JQuery.event.fix method is as follows

Fix:function (event) {
if (event[Jquery.expando]) {
return event;
}

Store a copy of the original event object
and "clone" to set read-only properties
var originalevent = event;
event = jquery.event (originalevent);

for (var i = this.props tutorial. length, prop; i;) {
Prop = this.props[-I.];
event[prop] = originalevent[prop];
}

Fix target property, if necessary
if (!event.target) {
Fixes #1925 where srcelement might is defined either
Event.target = Event.srcelement | | Document
}

Check if Target is a textnode (Safari)
if (Event.target.nodeType = = 3) {
Event.target = Event.target.parentNode;
}

Add Relatedtarget, if necessary
if (!event.relatedtarget && event.fromelement) {
Event.relatedtarget = Event.fromelement = = Event.target? Event.toElement:event.fromElement;
}

Calculate pagex/y if missing and clientx/y available
if (Event.pagex = = null && event.clientx!= null) {
var doc = document.documentelement,
BODY = document.body;

Event.pagex = Event.clientx + (Doc && Doc.scrollleft | | body && Body.scrollleft | | 0)-(Doc && do C.clientleft | | Body && Body.clientleft | | 0);
Event.pagey = Event.clienty + (Doc && Doc.scrolltop | | body && Body.scrolltop | | 0)-(Doc && do C.clienttop | | Body && Body.clienttop | | 0);
}

Add which for key events
if (Event.which = = null && (event.charcode!= null | | event.keycode!= null)) {
Event.which = Event.charcode!= null? Event.charCode:event.keyCode;
}

Add Metakey to Non-mac browsers (with Ctrl for PCs ' s and Meta for Macs)
if (!event.metakey && event.ctrlkey) {
Event.metakey = Event.ctrlkey;
}

Add which for click:1 = = left; 2 = = middle; 3 = = Right
Note:button isn't normalized, so don ' t use it
if (!event.which && event.button!== undefined) {
Event.which = (Event.button & 1 1: (Event.button & 2 3: (Event.button & 4 2:0));
}

return event;
},


It mainly did the following work
1,event = Jquery.event (originalevent); The sentence creates an instance object of the Jquery.event class, which is repaired and augmented just mentioned above.
2, a loop copies all the properties of the native event object to the event object in 1.

for (var i = this.props.length, prop; i;) {
Prop = this.props[-I.];
event[prop] = originalevent[prop];
}
3, the Unified Event source object is target.
4, the Unified event related object is Relativetarget.
5, expanded the Pagex, Pagey, these two attributes were first introduced in Firefox. Browsers that do not support this property are computed using clientx/y.
6, expands the which, uses it to obtain the keyboard key value (KeyCode). This attribute is also introduced in Firefox.
7, repaired the Metakey.
8, expands the which, uses it to obtain the mouse key value

Careful people may notice that jquery gets the keyboard key value and the mouse button value are all using which. It does not have the same properties as other attributes. The standard (button) of the consortium is already available. That's what I read in jquery Seven and the differences in the mouse button values in each browser are analyzed in detail.


jquery Event Analysis


*
* AUTHOR:PRK
* DATE:2008-08-17
* Comment:analyse of jquery Event
*
*/
Jquery.event = {

Add event to an element.
Add:function (Elem, types, handler, data) {
if (Elem.nodetype = = 3 | | elem.nodetype = = 8)//blank node or comment
Return

IE cannot pass in window, copy first.
if (JQuery.browser.msie && elem.setinterval)
Elem = window;

Assign a globally unique ID to the handler
if (!HANDLER.GUID)
Handler.guid = this.guid++;

Attach the data to the Handler.data
if (data!= undefined) {
var fn = handler;
Handler = This.proxy (FN, function () {//unique Id,wrap original handler fn
Return fn.apply (this, arguments);
});
Handler.data = data;
}

Initializes the events of the element. If the value in events is not taken, initialize data: {}


var events = Jquery.data (Elem, "events")


|| Jquery.data (Elem, "events", {}),


If the value in handle is not fetched, the data:function () {...} is initialized.


Handle = Jquery.data (Elem, "handle")


|| Jquery.data (Elem, "Handle", function () {


The second event that handles a trigger and an event is invoked after the page has been unload.


if (typeof jQuery!= "undefined"


&amp;&amp;!jquery.event.triggered)


return jQuery.event.handle.apply (//Arguments.callee.elem=handle.elem


Arguments.callee.elem, arguments);


});


Add Elem as the handle attribute to prevent IE leaking memory because there is no local event.


Handle.elem = Elem;

Processing uses a space to separate multiple event names, such as jquery (...). Bind ("Mouseo Tutorial ver mouseout", FN);
Jquery.each (Types.split (/s+/), function (index, type) {
namespace events, which are generally not used.
var parts = Type.split (".");
Type = Parts[0];
Handler.type = parts[1];

All processing functions bundled to this element type event
var handlers = Events[type];

if (!handlers) {//Initialize event queue without finding a list of handler functions
Handlers = Events[type] = {};

If type is not ready, or Ready's setup execution returns false


if (!jquery.event.special[type]


|| Jquery.event.special[type].setup


. Call (elem, data) = = False) {


Call the system's event function to register the event


if (Elem.addeventlistener)/FF


Elem.addeventlistener (type, handle, false);


else if (elem.attachevent)//IE


Elem.attachevent ("On" + type, handle);


}


}

Save the processor ID and handler form attribute pairs in the handlers list,
Also exists in Events[type][handler.guid].
Handlers[handler.guid] = handler;

Global cache usage Identity for this event
Jquery.event.global[type] = true;
});

Prevent IE memory leaks.
Elem = null;
},

Guid:1,
Global: {},

Remove an event from the element
Remove:function (Elem, types, handler) {
if (Elem.nodetype = 3 | | elem.nodetype = 8)
Return
Remove the FN list from the events of the element
var events = Jquery.data (Elem, "events"), RET, index;

if (events) {


Remove all occurrences of this element. is a namespace-handling


if (types = = undefined


|| (typeof types = = "string" &amp;&amp; types.charat (0) = = ".")


for (var type in events)


This.remove (Elem, type + types | | ""));


else {


types, handler parameter takes the form of {type:xxx,handler:yyy}


if (Types.type) {


handler = Types.handler;


types = Types.type;


}

Processing uses a space to separate multiple event names JQuery (...). Unbind ("MouseOver mouseout", FN);


Jquery


. each (Types.split (/s+/), function (index, type) {


namespace events, which are generally not used.


var parts = Type.split (".");


Type = Parts[0];

if (Events[type]) {//Event name found


if (handler)//handler incoming, this handler function for the Remove event name


The role of the delete Events[type][handler.guid];//guid


else//Remove all processing functions for this event, with namespace processing


For (handler in Events[type])


if (!parts[1]


|| Events[type][handler].type = = Parts[1])


Delete Events[type][handler];

If there is no handler function for the event, remove the event name


For (ret in events[type])//See there?


Break


if (!ret) {//No


if (!jquery.event.special[type]//not ready


|| Jquery.event.special[type].teardown


. Call (Elem) = = False) {//type is not equal to ready


if (Elem.removeeventlistener)//Remove event name in browser


Elem.removeeventlistener (Type,


Jquery.data (Elem,


"Handle"),


FALSE);


else if (elem.detachevent)


Elem.detachevent ("On" + type,


Jquery.data (Elem,


"Handle"));


}


ret = NULL;


The delete events[type];//is dropped in the cache.


}


}


});


}

No longer used, remove expando


For (Ret in events)


Break


if (!ret) {


var handle = Jquery.data (Elem, "handle");


if (handle)


Handle.elem = null;


Jquery.removedata (Elem, "events");


Jquery.removedata (Elem, "handle");


}


}


},

Trigger:function (type, data, Elem, donative, extra) {
data = Jquery.makearray (data);

if (Type.indexof ("!") >= 0) {//support! The NOT operation like! Click, except click All
Type = Type.slice (0,-1);//Except the last character?
var exclusive = true;
}

if (!elem) {//Handling Global Fire Events


if (This.global[type])


Jquery.each (Jquery.cache, function () {


All elements registered for the event are found from the cache and the handler function that triggers the Change event


if (this.events &amp;&amp; This.events[type])


JQuery.event.trigger (type, data, This.handle.elem);


});


else {//handling fire event for individual element events


if (Elem.nodetype = 3 | | elem.nodetype = 8)


return undefined;

var val, ret, fn = jquery.isfunction (Elem[type] | | | null),
Do we have to submit a forged event?
event =!data[0] | | !data[0].preventdefault;

Build a forged event.


if (event) {


Data.unshift ({//saved to the first of the array)


Type:type,


Target:elem,


Preventdefault:function () {


},


Stoppropagation:function () {


},


Timestamp:now ()


});


Data[0][expando] = true; No need to fix the forgery.


}

Prevent Event name Errors
Data[0].type = type;
if (exclusive)
Data[0].exclusive = true;

           //Trigger Events
             var handle = Jquery.data (Elem, "handle");
            if (handle)
                 val = handle.apply (elem, data);

           //Handle triggering native. OnFoo Handlers ( And on links since we
           //Don "T call. Click () for L Inks)
           //handle triggering. OnFoo such a local processing method, but for links ' s. Click () does not trigger
            if (!FN | | (Jquery.nodename (Elem, ' a ') && type = "click"))
                     && elem["on" + type]&& elem["on" + type].apply (elem, data) = False)
                 val = false;

Extra functions don ' t get the custom event object
if (event)
Data.shift ();

Handling Trigger Extra Events


if (extra &amp;&amp; jquery.isfunction (extra)) {


Executes the extra and saves the results in data.


ret = Extra.apply (elem, val = = null Data:data.concat (val));


If anything is returned, give it precedence and have it


Overwrite the previous value


if (ret!== undefined)


val = ret;


}

Triggering local Events


if (FN &amp;&amp; donative!== false &amp;&amp; val!== false


&amp;&amp;! (Jquery.nodename (Elem, ' a ') &amp;&amp; type = "click")) {


This.triggered = true;


try {


Elem[type] ();


For some hidden elements, ie will make an error


catch (e) {


}


}

This.triggered = false;
}

return Val;
},

Handle:function (event) {
return undefined or false
var val, ret, namespace, all, handlers;

event = Arguments[0] = JQuery.event.fix (Event | | window.event);

namespace processing
namespace = Event.type.split (".");
Event.type = namespace[0];
namespace = namespace[1];
All = True indicates any handler
all =!namespace &&!event.exclusive;
List of handler functions for the cached event names found in events of the element
Handlers = (Jquery.data (This, "events") | | {}) [Event.type];

for (Var j in handlers) {//each handler function executes
var handler = Handlers[j];

Filter the functions by class
if (all | | handler.type = = namespace) {
Incoming references, in order to delete them later
Event.handler = handler;
Event.data = Handler.data;

RET = handler.apply (this, arguments);//Execute event handler function

if (Val!== false)
val = ret;//This function returns false whenever one of the handler functions returns FALSE.

if (ret = false) {//Do not perform browser default action
Event.preventdefault ();
Event.stoppropagation ();
}
}
}

return Val;
},

Props: "Altkey attrchange attrname Bubbles button cancelable charcode"
+ "ClientY ctrlkey currenttarget Data detail eventphase fromelement handler KeyCode"
+ "Metakey newvalue originaltarget pagex pagey prevvalue relatednode relatedtarget ScreenX"
+ "ScreenY shiftkey srcelement target timeStamp toelement type view Wheeldelta which"
. Split (""),

Parcel out the event.
Fix:function (event) {
if (Event[expando] = = true)//indicates that the event has been wrapped
return event;

Save the original event and clone one at the same time.
var originalevent = event;
event = {
Originalevent:originalevent
};

for (var i = this.props.length, prop;i;) {


Prop = This.props[--i];


Event[prop] = Originalevent[prop];


}





Event[expando] = true;





Plus preventdefault and stoppropagation, not running in clone


Event.preventdefault = function () {


Run on the original event


if (Originalevent.preventdefault)


Originalevent.preventdefault ();





Originalevent.returnvalue = false;


};


Event.stoppropagation = function () {


Run on the original event


if (originalevent.stoppropagation)


Originalevent.stoppropagation ();





Originalevent.cancelbubble = true;


};

Fixed TimeStamp
Event.timestamp = Event.timestamp | | Now ();

Fixed target
if (!event.target)
Event.target = Event.srcelement | | Document
if (Event.target.nodeType = = 3)//Text node is the parent node.
Event.target = Event.target.parentNode;

Relatedtarget
if (!event.relatedtarget && event.fromelement)
Event.relatedtarget = Event.fromelement = = Event.target
? Event.toelement
: event.fromelement;

Calculate pagex/y if missing and clientx/y available


if (Event.pagex = = null &amp;&amp; event.clientx!= null) {


var doc = document.documentelement, BODY = document.body;


Event.pagex = Event.clientx


+ (Doc &amp;&amp; Doc.scrollleft | | body &amp;&amp; Body.scrollleft | | 0)


-(Doc.clientleft | | 0);


Event.pagey = Event.clienty


+ (Doc &amp;&amp; Doc.scrolltop | | body &amp;&amp; Body.scrolltop | | 0)


-(Doc.clienttop | | 0);


}

Add which for key events
if (!event.which
&& ((Event.charcode | | event.charcode = = 0)
? Event.charcode
: Event.keycode))
Event.which = Event.charcode | | Event.keycode;

       //ADD Metakey to Non-mac browsers (with Ctrl for PCs ' s and Meta for Macs)
        if (!event.metakey && event.ctrlkey)
             event.metakey = Event.ctrlkey;

Add which for click:1 = = left; 2 = middle; 3 = Right
Note:button isn't normalized, so don ' t use it
if (!event.which && Event.button)
Event.which = (Event.button & 1 1: (Event.button & 2
? 3
: (Event.button & 4? 2:0));

return event;
},

Proxy:function (FN, proxy) {
The role is to allocate global GUIDs.
Proxy.guid = Fn.guid = Fn.guid | | Proxy.guid | | this.guid++;
return proxy;
},

Special: {
Ready: {
Make sure the Ready event is setup
Setup:bindready,
Teardown:function () {
}
}
}
};

if (!jquery.browser.msie) {


Checks If a event happened on a element within another element


Used in JQuery.event.special.mouseenter and MouseLeave handlers


var withinelement = function (event) {


Check if Mouse (over|out) are still within the same parent element


var parent = Event.relatedtarget;


Traverse up the tree


while (parent &amp;&amp; parent!= This)


try {


parent = Parent.parentnode;


catch (e) {


parent = this;


}

if (parent!= this) {
Set the correct event type
Event.type = Event.data;
Handle event If we actually just moused on to a non sub-element
JQuery.event.handle.apply (this, arguments);
}
};

Jquery.each ({


MouseOver: ' MouseEnter ',


Mouseout: ' MouseLeave '


}, function (orig, fix) {


Jquery.event.special[fix] = {


Setup:function () {


JQuery.event.add (this, orig, withinelement, fix);


},


Teardown:function () {


JQuery.event.remove (this, orig, withinelement);


}


};


});


}

JQuery.fn.extend ({
Bind:function (type, data, fn) {
return type = = "Unload"? This.one (type, data, fn): this
. each (function () {//fn | | data, FN && data implements the data parameter optional
JQuery.event.add (this, type, fn | | data, fn && data);
});
},

Bind a one-time event handler for each matching element's specific event (like click).


On each object, this event handler is only executed once. The other rules are the same as the bind () function.


This event handler receives an event object that can be used to block the default behavior of the (browser).


This event handler must return FALSE if you want to cancel the default behavior and prevent the event from bubbling.


One:function (type, data, fn) {


var one = jQuery.event.proxy (fn | | data, function (event) {


JQuery (This). Unbind (event, one);


Return (fn | |/data). Apply (this, arguments);//this--&gt; Current element


});


Return This.each (function () {


JQuery.event.add (this, type, one, FN &amp;&amp; data);


});


},

A reverse operation of BIND (), which deletes the bound event from each matching element.
If there are no parameters, all bound events are deleted.
You can unbind the custom event you registered with BIND ().
If the event type is provided as a parameter, only the binding event of that type is deleted.
If the handler function passed at binding is used as the second argument, only this particular event handler is deleted.
Unbind:function (Type, fn) {
Return This.each (function () {
JQuery.event.remove (this, type, FN);
});
},




Trigger:function (type, data, fn) {


Return This.each (function () {


JQuery.event.trigger (type, data, this, true, FN);


});


},


This particular method will trigger the handler function for all bindings on the specified event type. However, the browser default action is not performed.


Triggerhandler:function (type, data, fn) {


return This[0]


&amp;&amp; JQuery.event.trigger (type, data, This[0], False, FN);


},





Call the function in turn after each click.


Toggle:function (FN) {


var args = arguments, i = 1;





while (I &lt; args.length)//per function assign GUID


JQuery.event.proxy (FN, args[i++]);

Return This.click (jquery.event


. Proxy (FN, function (event) {//Assign GUID


This.lasttoggle = (This.lasttoggle | | 0)% i;//previous function


Event.preventdefault ()//block default action


Executes the first function in the parameter, apply can take the Array-like parameter


With apply, the can use an array literal,


For example, fun.apply (this, [name, value]),


Or a array object, for example, fun.apply (this, new Array (name, value)).


Return Args[this.lasttoggle++].apply (This,


Arguments) | | False


}));


},





A method that mimics a hover event (the mouse moves over an object and removes it).


This is a custom method that provides a "stay in" state for frequently used tasks.


When the mouse is moved above a matching element, the first specified function is triggered. When the mouse moves out of this element,


Triggers the specified second function. Also, it is accompanied by a detection of whether the mouse is still in a particular element (for example, an image in a div),


If so, the hover state is maintained without triggering the emigration event (fixed a common error using the Mouseout event).


Hover:function (Fnover, fnout) {


Return This.bind (' MouseEnter ', fnover). Bind (' MouseLeave ', fnout);


},





EXECUTE FN when Dom ready


Ready:function (FN) {


Bindready ()//Register Monitor


if (Jquery.isready)//ready is running


Fn.call (document, JQuery);


Else


Add this function to the queue. It is visible to support countless ready calls.


JQuery.readyList.push (function () {


Return Fn.call (this, jQuery);


});

return this;
}
});

Jquery.extend ({


Isready:false,


Readylist: [],


Handle the DOM is ready


Ready:function () {


if (!jquery.isready) {


Jquery.isready = true;





if (jquery.readylist) {


Jquery.each (jquery.readylist, function () {


This.call (document);


});


Jquery.readylist = null;


}





JQuery (document). Triggerhandler ("Ready");


}


}


});

var readybound = false;

function Bindready () {
if (Readybound)
Return
Readybound = true;

Mozilla, Opera, WebKit nightlies support domcontentloaded Event
if (Document.addeventlistener &&!jquery.browser.opera)
Run when the domcontentloaded event is triggered Jquery.ready
Document.addeventlistener ("domcontentloaded", Jquery.ready, false);

ie or not frame window


if (jQuery.browser.msie &amp;&amp; window = top)


(function () {


if (Jquery.isready)


Return


try {


An exception is thrown all the time before Ondocumentready.


http://Web effects. nwbox.com/iecontentloaded/


Document.documentElement.doScroll ("left");


catch (Error) {


Run Bindready () (=arguments.callee)


settimeout (Arguments.callee, 0);


Return


}


Jquery.ready ();//documentready on the Run Jquery.ready


})();

if (JQuery.browser.opera)


Document.addeventlistener ("domcontentloaded", function () {


if (Jquery.isready)


Return


Only when the stylesheets fully enable, is the full load, in fact, there are pic


for (var i = 0;i &lt; document.styleSheets.length; i++)


if (document.stylesheets[i].disabled) {//by stylesheets to judge


settimeout (Arguments.callee, 0);


Return


}


Jquery.ready ();


}, False);

if (JQuery.browser.safari) {


var numstyles;


(function () {


if (Jquery.isready)


Return


First you have to get readystate=loaded or =complete.


if (document.readystate!= "loaded")


&amp;&amp; document.readystate!= "complete") {


settimeout (Arguments.callee, 0);


Return


}


Get the length of the style, compare the lengths between them to see if it's finished loaded


if (numstyles = = undefined)


Numstyles = JQuery ("style, Link[rel=stylesheet]"). Length;


if (document.styleSheets.length!= numstyles) {


settimeout (Arguments.callee, 0);


Return


}


Jquery.ready ();


})();


}

The last thing you can do is rely on window.load.
JQuery.event.add (window, "load", jquery.ready);
}

Adding common event methods for jquery objects


Jquery


. each (


("Blur,focus,load,resize,scroll,unload,click,dblclick,"


+ "Mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + "Submit,keydown,keypress,keyup,error")


. Split (","), function (i, name) {


Jquery.fn[name] = function (FN) {


RETURN FN? This.bind (Name, FN): This.trigger (name);


};


});

Prevent memory leaks in IE
and prevent errors on the refresh with the events like MouseOver in the other browsers
Window isn ' t included so as not to unbind existing unload events
JQuery (window). Bind (' Unload ', function () {
for (Var ID in Jquery.cache)
Skip the window
if (ID!= 1 && jquery.cache[id].handle)
JQuery.event.remove (Jquery.cache[id].handle.elem);
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.