The click() is an inbuilt method in jQuery that starts the click event or attach a function to run when a click event occurs.
Parameter: It accepts an optional parameter “function” which is used to run when a click event occurs.
Return Value: It returns the selected element with specified function to perform.
In the below code, no function is passed to this method.
Both outputs get generated simultaneously-
In the below code, function is passed to this method.
Before clicking inside the block-
After clicking inside the block-
- How to distinguish left and right mouse click using jQuery?
- How to perform click-and-hold operation inside an element using jQuery ?
- How to get relative click coordinates on the target element using JQuery?
- How to disable Copy, Paste, Cut and Right Click using jQuery ?
- How to click anywhere on the page except one element using jQuery ?
- How to get the coordinates of a mouse click on a canvas element ?
- How to add active class on click event in custom list group in Bootstrap 4 ?
- How to bind 'touchstart' and 'click' events but not respond to both ?
- How to make Bootstrap popover appear/disappear on hover instead of click?
- How to create a Ripple Effect on Click the Button ?
- How to convert the hamburger icon of navigation menu to X on click ?
- How to change an element color based on value of the color picker value on click?
- Vue.js | v-on:click directive
- v-on:click.middle Directive in Vue.js
- Vue.js v-on:click.right Directive
- Vue.js v-on:click.left Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.