JQuery Live (Type, FN) delegate event implementation _jquery

Source: Internet
Author: User
Currently support click, DblClick, MouseDown, MouseUp, MouseMove, MouseOver, Mouseout, KeyDown, KeyPress, KeyUp.
Also does not support blur, Focus, MouseEnter, MouseLeave, change, submit
Unlike bind (), Live () can only bind one event at a time.
This approach is similar to traditional bind, except that using live to bind events gives all current and future elements of the page a binding event (using delegated methods). For example, if you bind the click event to all the Li on the page with live. So when you add an Li to this page later, the Click event for this newly added Li is still available. Without having to give this newly added element binding event.
Live () is similar to popular livequery Plug-ins, but there are several main differences:
*. Live currently supports only a subset of all events, supported by a list reference above.
*. Live does not support livequery-provided "no event" style callback functions. Live can only bind event handler functions.
*. Live without the "setup" and "cleanup" process. Because all events are delegated rather than directly bound to the element.
To remove live-bound events, use the Die method
return value
Jquery
Parameters
Type (String): One or more space-delimited event names
fn (function): event handler to bind
Example
Clicking on the generated p still holds the same function.
HTML Code:
<p>click me!</p>
JQuery Code:
Copy Code code as follows:

$ ("P"). Live ("Click", Function () {
$ (this). After ("<p>another paragraph!</p>");
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.