Home > Web Front-end > JS Tutorial > Example of usage of delegate() method in jQuery_jquery

Example of usage of delegate() method in jQuery_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:19:21
Original
1202 people have browsed it

The example in this article describes the usage of delegate() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method adds one or more events to the child elements of the matched element and specifies a function to run when these events occur.

Grammar structure:

Copy code The code is as follows:
$(selector).delegate(childofselector,type,data,function)

Parameter list:

Parameters Description
childofselector Define one or more child elements to which event handlers are attached.
type Optional. Defines one or more event types to attach to the element. Multiple event values ​​separated by spaces.
data Define additional data passed to the event handler.
function Define a function to run when an event occurs.

Example code:

Copy code The code is as follows:






Script Home







  • Script House welcomes you






The above code can register a click event handler for the button element, a sub-element of the div. When the button is clicked, it can switch between hiding and displaying.

I hope this article will be helpful to everyone’s jQuery programming.

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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template