X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery click() Method

jQuery Event Methods 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 jQuery Event Methods


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook