Home > Web Front-end > JS Tutorial > Read jQuery 10 Event Module Overview_jquery

Read jQuery 10 Event Module Overview_jquery

WBOY
Release: 2016-05-16 18:05:37
Original
923 people have browsed it

jQuery.event.add/jQuery.event.remove/jQuery.event.trigger will be analyzed in detail later.

Although the event module code is difficult to read, the API interface it provides is still very clear. As follows
Read jQuery 10 Event Module Overview_jquery
1 Add event (bind/one/live/delegate/hover/toggle)
bind is the basic adding event function.
one adds an event function that only executes once.
live event proxy (using document proxy).
delegate event delegate (use the specified element delegate).
hover simulates CSS hover.
toggle show/hide.

bind/one/live all use the internal jQuery.event.add to complete event addition.
Delegate internally calls live.
hover uses mouseenter/mouseleave internally, and mouseenter/mouseleave uses bind.
toggle uses click internally, and click internally calls bind.

In fact, a jQuery each call adds 24 shortcut methods for adding events to the jQuery object
As shown below

As shown below

Read jQuery 10 Event Module Overview_jquery


Remember, bind calls jQuery.event.add, so jQuery.event.add is the core of the entire jQuery add event module. All the above methods are upper-layer applications built on top of it. As shown in the picture

Read jQuery 10 Event Module Overview_jquery


2 Delete event (unbind/die/undelegate)

unbind deletes the event base method. You can delete a specified handler, you can also delete all handlers for a certain type of event, and you can even delete all events hanging on the element. Internally it calls jQuery.event.remove.

die/undelegate deletes the event delegate. Unbind is used internally.


Therefore, jQuery.event.remove is the core of the entire jQuery delete event module. unbind/die/undelegate are all upper-layer applications built on top of it. As shown in the picture

Read jQuery 10 Event Module Overview_jquery


3 Trigger event (trigger/triggerHandler)

trigger triggers an event (bubbles)

triggerHandler triggers an event (will not bubble)


trigger/triggerHandler internally calls jQuery.event.trigger, so jQuery.event.trigger is the core of the entire jQuery trigger event module. As shown in the picture
Read jQuery 10 Event Module Overview_jquery

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template