On the difference between band (). Live (). Delegate (). On () in jquery.

Source: Internet
Author: User

Bind (TYPE,[DATA],FN) binds event handlers for specific events of each matching element

$ ("a"). Bind ("click", Function () {alert ("OK");});

Live (TYPE,[DATA],FN) attaches an event handler function to all matching elements, even if the element is added later in the

$ ("a"). Live ("Click", Function () {alert ("OK");});

delegate (SELECTOR,[TYPE],[DATA],FN) the specified element (which belongs to the child element of the selected element) adds one or more event handlers and specifies the function to run when these events occur

$ ("#container"). Delegate ("A", "click", Function () {alert ("OK");})

On (EVENTS,[SELECTOR],[DATA],FN) an event handler that is bound to one or more events on the selection element

Difference:

@1. Bind () is directly bound on the element

@2. Live () is bound to an element by a bubbling way. More appropriate for the list type, bound to the document DOM node. and. Bind () have the advantage of supporting dynamic data.

@3. Delegate () is a more accurate, small-scale use of event proxies with better performance. Live ()

@4. On () is the latest 1.9 version of the new event binding mechanism that incorporates the previous three ways

On the difference between band (). Live (). Delegate (). On () in jquery.

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.