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()
Call
What it does
Click
Learn 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
Parameter
Description
Step 1
Select the element(s): $("#btn"), $("p"), etc.
Step 2
Bind: .on("click", function (event) { ... }).
Step 3
Use $(this) for the bound element; read event for details.
Return Value
Return Value
Description
jQuery object
Most 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.");
});
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");
});
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
Click bubbles from the li (or its children) to the list.
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.