📅  最后修改于: 2020-11-26 07:12:58             🧑  作者: Mango
委托()方法用于为指定元素(是所选元素的子元素)附加一个或多个事件处理程序。此方法执行事件发生时要运行的函数。
附加的带有委托()方法的事件处理程序适用于当前和将来的元素。
句法:
$(selector).delegate(childSelector,event,data,function)
Parameters | Description |
---|---|
ChildSelector | It is a mandatory parameter that is used to specify one or more child elements to attach the event handler. |
Event | It is also a mandatory parameter. It specifies one or more events to attach to the elements. If you use multiple events then they must be separated by space. |
Data | It is optional and specifies additional data to pass along to the function. |
Function | It is executed when the event occurs. |
让我们以jQuery委托()为例。
delegate demo
This is a single paragraph. Click me for next.