JQuery event processing and jquery event processing
Browser event model DOM level 0th event model
When an event on an element in the dom tree is triggered, the event model checks whether the element has created a specific event processor. If yes, the created event processor is called. Then, the event model checks the parent element of the target element to see if it has created a processor for this event type. If yes, call the created processor and check its parent element, parent element of the parent element, and so on until the top of the dom tree.
DOM level 2nd event model IE event model jQuery event model bind event processor with jQuery
Bind (eventType, data, handler); bind (eventMap)
You can add a suffix separated by dots to the event name to specify a namespace to operate event processors in batches.
You can bind multiple events to an element using a single bind () method.
$('.whatever').bind({ click:function(event){/* handle */}, mouseenter: function (event) {/* handle */ }, mouseleave: function (event) {/* handle */ }})
Binding specific events:
Blur change click dblclick error focus focusin focusout keydown keypress keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup ready resize scroll select submit unload
When you use these convenient methods, the event. data value is read-only. They have a listener function, indicating the event processor.
Focusin focusout
One (eventType, data, listener)
Delete event Processor
Unbind (eventType, listener); unbind (event)
Delete a specific event Processor
Delete all event processors in the namespace
$('*').unbind('.fred')
Event instance
JQuery. Event attributes and Methods independent of browsers
Name |
Description |
AltKey |
|
CtrlKey |
|
CurrentTarget |
|
Data |
|
MetaKey |
|
PageX |
|
PageY |
|
RelatedTarget |
|
ScreenX |
|
ScreenY |
|
ShiftKey |
|
Result |
|
Target |
|
Timestamp |
|
Type |
|
Which |
|
PreventDefault () |
|
StopPropagation () |
|
StopImmediatePropagation () |
|
IsPropagationStopped () |
|
IsImmediatePropagationStopped () |
|
Pre-managed event processor (deprecated) trigger event Processor
Trigger (eventType, data)
TriggerHandler (eventType, data)
Convenient Method for triggering
Blur () change () click () dblclick () error () focus () focusin () focusout () keydown () keypress () keyup () load () mousedown () mouseenter () mouseleave () mousemove () mouseout () mouseover () mouseup () resize () scroll () select () submit () unload ()
Other event-related methods make full use of (more) Event Filtering large data sets
Create an element by copying a template
Create subject tag
Add a new filter
Add a restricted control
Delete unnecessary filters and other tasks
There is always room for improvement