Detailed explanation of how to use jQuery.delegate() function
黄舟
Release: 2017-06-26 10:49:14
Original
1688 people have browsed it
delegate() The function is used to bind one or more events for the specified element Event processing function .
In addition, you can also pass some additional required data to the event handling function.
Even if it is a newly added element after executing the delegate() function, as long as it meets the conditions, the bound event handling function is still valid for it.
In addition, this function can bind multiple event processing functions to the same element and the same event type. When an event is triggered, jQuery will execute the bound event processing functions in the order of binding. To delete an event bound through delegate(), use the undelegate() function. Starting from jQuery 1.7, please use the event function on() instead of this function. This function belongs to the jQuery object (instance). SyntaxjQuery
1.4.2 Add this function. It mainly has the following two forms of usage:
Usage one:
jQueryObject.delegate( selector , events [, data ], handler )
Copy after login
Usage two:jQuery 1.4. 3 Added support for this usage.
jQueryObject.delegate( selector, eventsMap )
Copy after login
Parameters
Parameters
Description
selector
String type is a jQuery selector used to specify which descendant elements can trigger bound events. If this parameter is null or omitted, it means that the current element itself is bound to the event (the actual triggerer may also be a descendant element, as long as the event stream can reach the current element).
The above is the detailed content of Detailed explanation of how to use jQuery.delegate() function. For more information, please follow other related articles on the PHP Chinese 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