Home > Article > Web Front-end > Is click a jquery event?
Click is a jquery event. Click is used to set the event that is triggered when the element is clicked; when the mouse pointer stays over the element and the left button is clicked, the click event will be triggered or specified to run when the click event occurs. Function, the syntax is "element object.click (run function)".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
Click is a jquery event
The click method (in jquery) is used to trigger the onclick event, as long as the element is executed The click() method will trigger the onclick event.
The main function of the click() method is to trigger the onclick event of the element that calls the click method, which actually simulates the click action of the mouse. In addition, if other executable statements are defined within the click brackets, the click method will execute the statements inside the brackets after the onclick event is executed.
When an element is clicked, the click event occurs.
The click() method triggers a click event, or specifies a function to run when a click event occurs.
Syntax
Trigger the click event of the selected element:
$(selector).click()
Add a function to the click event:
$(selector).click(function)
The example is as follows:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>123</title> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").click(function(){ alert("段落被点击了。"); }); }); </script> </head> <body> <p>点击这个段落。</p> </body> </html>
Output result:
After clicking on the paragraph:
## Recommended related video tutorials:The above is the detailed content of Is click a jquery event?. For more information, please follow other related articles on the PHP Chinese website!