Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery click() method

jQuery click() method

jQuery event methods jQuery event methods

Example

Click the

element, alert text:

$("p").click(function(){

    alert("The paragraph was clicked.");

});

Try it »


Definition and Usage

The click event occurs when an element is clicked.

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


Syntax

Trigger the click event of the selected element:

$(

selector

).click()

Try it

Add a function to the click event:

$(

selector

).click(

function

)

Try it

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

jQuery event methods jQuery event methods