I. Common events are: Click, DblClick, MouseDown, MouseUp, MouseMove, MouseOver, mouseout, change, select, Submit, KeyDown, KeyPress, KeyUp, Blur, focus, load, resize, scroll, error .....
Two. Query uses the. bind () method to bind the elements to these events. Three parameters can be passed: Bind (TYPE,[DATA],FN):
Type represents one or more types of event name strings.
[Data] is optional, passing an extra data as the value of the Event.data property, which is a string, a number, an array, or an object.
FN represents the handler function that is bound to the specified element.
Premise: Introduction of jquery Packages
Prepared HTML: To be Continued
Part I: Adding Binding Events: Bind ()
1. Anonymous functions
// Use Click events
$ ('input'). Bind ('click'/// Click button to execute anonymous function alert (' click! '
});
Explanation: Binding The Click event to an element, function () {}.
2. General functions
// General processing Functions $ ('input'). Bind ('click'// Perform a normal function without parentheses function fn () {alert (' click! '); }
Explanation: Called by a function name. Further binding on the event.
3. Bind multiple events at the same time
// multiple events can be bound at the same time $ ('input'). Bind ('mouseout mouseover'// $ (' div '). html (function (index,value) { ReturnValue+'1';}); });
4. Object key-value pairs bind multiple parameters (functions)
//to bind multiple parameters by object key-value pairs $('input'). Bind ({//passing an object 'mouseout': function () {//The quotation marks of the event name can be omitted
Alert ('Move out'); }, 'mouseover': Function () {alert ('Move in'); } });
Part II: Delete Binding event: Unbind ()
1. Delete the current element event used
// to delete a bound event using Unbind $ ('input'). Unbind (); // Delete events for all current elements
2. Delete the specified event
$ (' input '). Unbind (' click '// Delete The Click event for the current element
3. Delete the specified function
//use the unbind parameter to delete an event that specifies a handler functionfunction fn1 () {alert ('Click 1'); } functionfn2 () {alert ('Click 2'); }$('input'). Bind ('Click', FN1); $('input'). Bind ('Click', FN2); $ ('input'). Unbind ('Click', FN1);//only events that remove the FN1 handler function
jquery Foundation Events