Sat.
: Event Processing
Hover (function, function) triggers the first function when the mouse moves over, and triggers the second function when the mouse moves out.
Style: <style>. Red {color: # ff0000} </style>
HTML code: <Div id = "A"> SDF </div>
Jquery code and Effects
$ (Function (){
$ ("# A"). Hover (function () {$ (this). addclass ("red ");},
Function () {$ (this). removeclass ("red ");
});
})
The final result is that when you move the mouse over the layer with ID a, a red style is added to the layer and the red style is removed when the layer is left.
Toggle (function) triggers the first function when a matching element is clicked for the first time.
Style: <style>. Red {color: # ff0000} </style>
HTML code: <Div id = "A"> SDF </div>
Jquery code and Effects
$ (Function (){
$ ("# A"). Toggle (function () {$ (this). addclass ("red ");},
Function () {$ (this). removeclass ("red ");
});
})
The final effect is to add a red style to the layer when you click the layer with ID a and remove the red style when you leave the layer.
The BIND (type, FN) User binds an event and the method of triggering the event to the matching object.
Trigger (type) triggers type-based events. $ ("P"). Trigger ("click ")
Also:Unbind () unbind (type, FN)
Dynamic event (function) binding and unbinding provides a simple method for Functions
Example:
$ ("# A"). BIND ("click", function (){
$ (This). addclass ("red ");
})
You can also write as follows:
$ ("# A"). Click (function (){
$ (This). addclass ("red ");
});
The final effect is to add a red style to the layer when you click the layer with ID,
Functions provided by jquery
Used for browers events
Error (FN) load (FN) unload (FN) resize (FN) scroll (FN)
Used for Form Events
Change (FN) Select (FN) Submit (FN)
Used for Keyboard Events
Keydown (FN) keypress (FN) keyup (FN)
Used for mouse events
Click (FN) dblclick (FN) mousedown (FN) mousemove (FN)
Mouseout (FN) Mouseover (FN) mouseup (FN)
Used for UI events
Blur (FN) Focus (FN)
The above events are extended to 5 categories.
For example, click (FN) extended click () unclick () oneclick (FN) unclick (FN)
Click (FN): adds an event that triggers a function when a click is added.
Click (): Click events that match objects can be executed in other events.
Unclick (): The Click Event of the matching object is not executed.
Oneclick (FN): adds a click event that can be executed once.
Unclick (FN): adds an event that does not trigger a function when a click is added.
Used for browers, form, and keyboard