Home >Web Front-end >JS Tutorial >jQuery trigger() method usage introduction_jquery

jQuery trigger() method usage introduction_jquery

WBOY
WBOYOriginal
2016-05-16 16:20:461602browse

Introduction to the usage of jQuery’s trigger() method:
This method triggers an event of the specified type on the matched element.
It has two syntax formats, which are introduced below.
Grammar structure 1:

Copy code The code is as follows:

$(selector).trigger(event,[param1,param2,...])

Parameter analysis:

1.event: required, specifies the event to be triggered by the matching element, which can be a custom event or a standard event.
2.param: optional, parameters passed to the event processing function.

Code example:

Copy code The code is as follows:





Ant Tribe








In the above code, the select event handler is registered for the text box. When the text in the text box is selected, the text inside will turn red.
When the button is clicked, the trigger() method will be used to trigger the select event on the matching element.
Grammar structure 2:

Copy code The code is as follows:

$(selector).trigger(eventObj)
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