Home >Web Front-end >JS Tutorial >The definition and usage of click event in jQuery_jquery

The definition and usage of click event in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:25:131253browse

The examples in this article describe the definition and usage of click events in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

When the mouse pointer is over the matching element, then pressing and releasing the left mouse button or calling the click() method will trigger the click event.

The click() method can also bind event handling methods.

Grammar structure 1:
Trigger click event.

Copy code The code is as follows:
$(selector).click()

Grammar structure 2:
Bind an event handling method to the click event.

Copy code The code is as follows:
$(selector).click(data,function)

Parameter list:

参数 描述
data 可选。定义传入供function处理的数据。
function 定义click事件触发时运行的函数。

Example code:

Copy code The code is as follows:





click event-Script Home






Double-click me to trigger the click event




The above code will set new text in the div when the p element is double-clicked or the button is clicked.

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