Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

jQuery click() Method

❮ jQuery Event Methods

Example

Click on a <p> element to alert a text:

$("p").click(function(){
  alert("The paragraph was clicked.");
});
Try it Yourself »

Definition and Usage

The click event occurs when an element is clicked.

The click() method triggers the click event, or attaches a function to run when a click event occurs.


Syntax

Trigger the click event for the selected elements:

$(selector).click() Try it

Attach a function to the click event:

$(selector).click(function) Try it

Parameter Description
function Optional. Specifies the function to run when the click event occurs

❮ jQuery Event Methods