Although we can use event handling functions to complete almost all operations on object events, jQuery provides encapsulation of common events. For example, the two methods click() and click(fn) corresponding to click events are used to trigger single clicks respectively. Click event and set click event.
Set click event:
$("#testDiv").click(function(event) { alert("test div clicked ! "); });
Equivalent to:
$("#testDiv").bind("click", function(event) { alert("test div clicked ! "); });
Trigger click event:
$("#testDiv").click();
Equivalent to
$("#testDiv").trigger("click");
Note that the equivalent here is trigger instead of triggerHandler.
This type of method is called Event Helpers in jQuery in English. I couldn't find a good translation method, so I called it "shortcut method" according to the function. We are collecting good translation names!
The following is jQuery List of shortcut methods:
Since they are all corresponding events, I won’t write explanations and examples anymore.
Name | Description | Example |
blur( ) | ||
##blur( fn ) | ||
change( ) | ||
change( fn ) | ||
##click( ) | ||
click( fn ) | ||
dblclick( ) | ||
keypress( ) | # | |
keypress( fn ) | # | # |
#keyup( ) | ||
keyup( fn ) | ||
load( fn ) | ||
mousedown( fn ) | # | |
mouseenter( fn ) | # | |
##mouseleave( fn ) | ||
# #mousemove( fn ) | ||
#mouseout( fn ) | ||
#mouseover( fn ) | # | |
mouseup( fn ) | # | |
resize( fn ) | ||
###### #scroll( fn )### | ||
select( ) | ||
select( fn ) | ||
submit( ) | ||
submit( fn ) | ||
unload( fn ) |