2 Demos to use jQuery click() event method

2 Demos to use jQuery click() event method

What is the jQuery click() method?

The click event occurs when an element of HTML document is clicked. For example clicking a button, a paragraph, a Div, a link or an image etc. As click event occurs, an event handler function can be attached to perform a certain action with the click() method.

Video Tutorial

How to use the click method


Where the function is optional. It runs as click event occurs.


  • $(“p”).click(function)
  • $(“div”).click(function)
  • $(“button”).click(function)

Below are running examples of click() method with different HTML elements

Example of click() with paragraph

In the example below, as the first paragraph is clicked, it will trigger an event handler that will show an alert. The click method is attached with clickme id.

Copy and paste code into HTML file and run in your browser.

jQuery click

Experience this example online

Example of jQuery click() with Div <div>

Just like the above example except the div tags are used for demonstrating the click jQuery method:

Experience this example online

Also see jQuery events