JQuery (i) delegate () method

Source: Internet
Author: User

Definition and usage

The delegate () method adds one or more event handlers for the specified element (the child element of the selected element) and specifies the function to run when these events occur.

Event handlers that use the delegate () method apply to current or future elements, such as new elements created by a script.

Grammar
$ (selector). Delegate (Childselector,event,data,function)

Parameters Description
Childselector Necessary. Specifies one or more child elements to attach the event handler.
Event

Necessary. Specifies one or more events that are attached to an element.

Multiple event values are separated by a space. Must be a valid event.

Data Optional. Specifies additional data that is passed to the function.
function Necessary. Specifies the function to run when an event occurs.

undelegate () methodInstance

Removes all event handlers added by the delegate () method from all elements:

$ ("Body"). Undelegate ();

Definition and usage

The Undelegate () method deletes one or more event handlers that were added by the delegate () method.

Grammar
$ (selector). Undelegate (selector,event,function)

Parameters Description
Selector Optional. Specifies the selector that needs to delete the event handler.
Event Optional. Specifies one or more event types for which the handler function needs to be deleted.
function Optional. Specifies the specific event handler to delete.

Try it yourself-example
Delete event handlers, added by delegate (), from a specific selector
How to use the Undelegate () method to remove all event handlers from the specified element.
Deletes an event handler for the specified event type, added by delegate (), from the specified element
How to use the Undelegate () method to remove all event handlers for a specific event type from the specified element.
Delete the specific function added by delegate ()
How to use the Undelegate () method to remove specific functions from a specific event type for an event handler.

JQuery (i) delegate () method

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.