jQuery Event - click() Method

Example

Hide or show the element when the button is clicked:

$("button").click(function(){
  $("p").slideToggle();
});

Try It Yourself

Definition and Usage

A click event occurs when an element is clicked.

A click occurs when the mouse pointer is placed over an element, then the left mouse button is pressed and released.

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

Triggers a click event

Syntax

$(selector).click()

Try It Yourself

Binds the function to the click event

Syntax

$(selector).click(function)
Parameter Description
function Optional. Specifies the function to be executed when a click event occurs.

Try It Yourself