Home >Web Front-end >JS Tutorial >Usage examples of triggerHandler() method in jQuery_jquery

Usage examples of triggerHandler() method in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:19:271309browse

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

This method triggers the specified event type of the selected element.
From the above definition, we can see that this method is very similar to the trigger() method in function, but there is still a huge difference. Here are the main differences:

1. This method will not trigger browser default events.
2. This method triggers the event processing function of the first element in the jQuery object collection and does not cause event bubbling.
3. This method returns the return value of the event handling function, not the chainable jQuery object.

Grammar structure:

Copy code The code is as follows:
$(selector).triggerHandler(event,[param1,param2,. ..])

Parameter list:

参数 描述
event 规定指定元素要触发的事件类型。
param 可选。传递到事件处理程序的额外参数。

Example code:

Copy code The code is as follows:






Script Home









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

Statement:
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