jQuery Click Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Mouse Events

Definition

click is sent when the mouse button is pressed and released while the pointer stays inside an element. Bind it with .on("click", handler) (jQuery 1.7+).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#target").on("click", function () { ... })
$("#target").trigger("click")

// Needs: mousedown + mouseup inside the element
// Prefer on/trigger — not the deprecated .click()
CallWhat it does
ClickLearn the jQuery click event: bind with .on(\

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select the element(s): $("#btn"), $("p"), etc.
Step 2Bind: .on("click", function (event) { ... }).
Step 3Use $(this) for the bound element; read event for details.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Bind a Click Handler

Official style: .on("click", …) on a target element.

jQuery
$("#target").on("click", function () {
  console.log("Handler for click called.");
});
Try It Yourself

How It Works

  1. Select #target.
  2. Bind with .on("click", handler).
  3. User clicks — press and release inside the element.

Example 2 — Trigger a Click from Code

Fire the same handlers without a real mouse click.

jQuery
$("#target").on("click", function () {
  console.log("Handler for click called.");
});

$("#other").on("click", function () {
  $("#target").trigger("click");
});
Try It Yourself

How It Works

  1. Bind the real handler on #target.
  2. Another control listens for its own click.
  3. trigger("click") runs #target’s click handlers.

Example 3 — Event Delegation

One parent handler covers current and future children.

jQuery
$("#list").on("click", "li", function () {
  console.log("Clicked: " + $(this).text());
});

// Later…
$("#list").append("<li>New item</li>");
// New item is clickable too — no extra bind
Try It Yourself

How It Works

  1. Bind on parent #list, filter with "li".
  2. Click bubbles from the li (or its children) to the list.
  3. this is the matched li.

Frequently Asked Questions

click fires when the mouse button is pressed and released while the pointer stays inside the element. Bind with .on("click", handler) (jQuery 1.7+). Any HTML element can receive it.
Prefer .on("click", handler). The .click(handler) shorthand is deprecated since jQuery 3.3. To fire the event, use .trigger("click") instead of .click().
click needs both press and release inside the same element. mousedown fires on press; mouseup on release. Use mousedown/mouseup when you do not need the full click sequence.
Call $(selector).trigger("click"). That runs bound handlers (and default actions). Use .triggerHandler("click") to run handlers without default browser behavior.
Bind once on a parent: $("#list").on("click", "li", fn). Clicks on matching children (including ones added later) bubble to the parent and run the handler.
this is the element the handler is bound to (or the matched child with delegation). event.target is the deepest node actually clicked — often a child inside this.

Next: .click() Method

See the deprecated helper and how it maps to on / trigger.

.click() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful