The click event fires when the user presses and releases the mouse button inside an element. This tutorial covers binding with .on("click"), passing eventData, triggering with .trigger("click"), comparing click with mousedown and mouseup, and event delegation for dynamic content.
01
.on()
Bind handler
02
eventData
Pass data
03
.trigger()
Fire click
04
Sequence
Down + up
05
Delegate
Dynamic lists
06
Since 1.7
Modern API
Fundamentals
Introduction
Almost every interactive web page responds to clicks — buttons submit forms, tabs switch panels, and list items toggle state. jQuery makes binding click handlers straightforward: select elements, call .on("click", handler), and run your function when the user completes a full press-and-release inside the element.
The official jQuery API distinguishes the clickevent (bound with .on("click") since 1.7) from the deprecated .click()method used for binding in older code. To programmatically fire a handler, use .trigger("click") — available since jQuery 1.0. Any HTML element can receive the click event.
Concept
Understanding the click Event
The click event is sent to an element when the mouse pointer is over the element and the mouse button is pressed and released. jQuery normalizes this across browsers and gives you a consistent event object with properties like event.target, event.pageX, and event.preventDefault().
Click fires only after this exact sequence: the mouse button is depressed while the pointer is inside the element, then released while the pointer is still inside. If the user presses inside but releases outside, no click fires on that element. When you need action on press or release alone — not the full gesture — mousedown or mouseup may be more suitable.
💡
Beginner Tip
Inside a handler, $(this) refers to the element that matched the binding (or the delegated child). Use event.target when you need the deepest element actually clicked — useful when children overlap inside a button or list item.
Foundation
📝 Syntax
The modern jQuery API for the click event has two main forms — binding a handler and triggering the event:
.on() and .trigger() return the original jQuery object for chaining.
Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).
Cheat Sheet
⚡ Quick Reference
Goal
Code
Bind click handler
$("#btn").on("click", fn)
Pass data to handler
$("#btn").on("click", { id: 1 }, fn)
Delegated click on children
$("#list").on("click", "li", fn)
Trigger click programmatically
$("#target").trigger("click")
Trigger all matched elements
$("p").trigger("click")
Remove click handlers
$("#btn").off("click")
One-time click
$("#btn").one("click", fn)
Compare
📋 click vs mousedown vs mouseup vs deprecated .click()
Four ways to respond to mouse interaction — choose the event that matches the user gesture you need.
click
down+up
Full press-and-release inside element — default for buttons and links
mousedown
press
Fires when button is pressed — before release; good for drag start
mouseup
release
Fires when button is released — regardless of where press started
.click() method
deprecated
Old binding shorthand — use .on("click") instead
Hands-On
Examples Gallery
Examples 1–4 follow the official jQuery API documentation. Example 5 demonstrates event delegation for dynamic lists. Use the Try-it links to run each snippet in the browser.
📚 Binding & Triggering
Official jQuery demos for click handlers and programmatic triggers.
Example 1 — Official Demo: Bind Handler on #target
Alert when the user clicks the target element — the canonical .on("click") pattern.
User clicks #target → alert: "Handler for click called."
Handler runs once per full click (mousedown + mouseup inside)
How It Works
.on("click", fn) registers the function on the element. jQuery calls it when the browser fires a completed click — pointer down and up both occurred inside #target.
Example 2 — Official Demo: #other Triggers Click on #target
One element programmatically fires the click handler on another.
.trigger("click") synthetically fires the click event on #target, running the same handler as a physical click. Useful for keyboard shortcuts, form automation, or proxy buttons.
Example 3 — Official Demo: Hide Paragraphs on Click
Each paragraph slides up and hides when clicked — a common dismiss pattern.
Click "First Paragraph" → slides up and hides
Click "Second Paragraph" → same animation on that p only
$(this) refers to the clicked paragraph
How It Works
Binding to all p elements runs one handler per paragraph. Inside the handler, $(this) is the specific paragraph clicked — so .slideUp() animates only that node.
Example 4 — Official Demo: Trigger Click on All Paragraphs
Programmatically fire the click event on every matched element at once.
After handlers are bound on each p:
$("p").trigger("click") → every handler runs once
Useful for batch actions or testing
How It Works
When the jQuery collection contains multiple elements, .trigger("click") fires the event on each one in turn. Every bound handler on each paragraph executes — order follows DOM order.
📈 Event Delegation
Handle clicks on elements that do not exist yet when the page loads.
Example 5 — Delegated Click on Dynamic List Items
Bind once on the parent #list — clicks on current and future li elements are handled.
Click existing li → toggles .done class
Append new li via JavaScript → click still works
One handler on #list covers all li children
How It Works
jQuery listens for clicks on #list and checks whether the event target matches li. If so, it runs the handler with this set to that list item. New items added with .append() need no extra binding — the parent handler covers them.
Applications
🚀 Common Use Cases
Button actions — $("#submit").on("click", fn) to validate forms or send AJAX requests.
EventData labels — $(".star").on("click", { rating: 5 }, fn) to pass metadata without closures.
🧠 How the click Event Flows
1
Pointer down inside
User presses mouse button while cursor is over the element — mousedown fires first.
mousedown
2
Pointer up inside
User releases button while cursor is still inside the same element — mouseup fires.
mouseup
3
Click event fires
Browser sends click — jQuery runs bound handlers via the event system.
click
4
👉
Handler runs
Your function executes — $(this) is the element; return false to cancel default action.
Important
📝 Notes
Bind with .on("click", handler) since jQuery 1.7 — not the deprecated .click(handler) method.
Trigger with .trigger("click") since jQuery 1.0.
Click requires mousedown and mouseup both inside the element — release outside cancels click.
Any HTML element can receive the click event — not limited to <button> or <a>.
Use .off("click") to remove handlers — avoid deprecated .unbind("click").
Touch devices synthesize click after tap — there may be a ~300ms delay on older mobile browsers.
For keyboard accessibility, ensure clickable non-button elements have role="button" and tabindex="0".
Compatibility
Browser Support
The click event is a standard DOM event supported in every browser jQuery targets. jQuery’s .on("click") (since 1.7) and .trigger("click") (since 1.0) normalize cross-browser behavior — you write one API regardless of IE quirks in older jQuery builds.
✓ jQuery 1.7+
jQuery click event
Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery versions. Native equivalent: element.addEventListener('click', fn) — jQuery adds collection binding, eventData, delegation, and .trigger() in one chainable API.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
clickUniversal
Bottom line: Safe in any jQuery project. Prefer .on('click') over deprecated .click() for binding. Use delegation for dynamic content.
Wrap Up
Conclusion
The jQuery click event is the standard way to respond when a user completes a press-and-release inside an element. Bind handlers with .on("click", fn), pass optional eventData, and fire handlers programmatically with .trigger("click").
Remember the official sequence: mousedown inside, then mouseup inside — only then does click fire. Use mousedown or mouseup when you do not need the full gesture. For lists and tables that grow at runtime, delegate with $("#parent").on("click", "child", fn). Remove handlers with .off("click") when cleaning up.
Bind with .on("click", handler) — the modern, delegation-capable API
Use event delegation for dynamic content: .on("click", "li", fn)
Call .off("click") when removing elements or single-page app teardown
Use event.preventDefault() to stop link navigation when needed
Prefer semantic <button> elements for clickable controls
❌ Don’t
Use deprecated .click(handler) for new code — use .on("click")
Bind individual handlers inside loops for list items — delegate instead
Confuse click with mousedown — click needs both down and up inside
Assume this === event.target — they differ when children are clicked
Trigger click on hidden file inputs without user intent — respect browser security
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about the click event
Bind, trigger, delegate.
6
Core concepts
.on01
.on("click")
Bind
API
⚡02
.trigger()
Fire
Programmatic
↓↑03
Down + up
Sequence
Behavior
li04
Delegate
Dynamic
Pattern
this05
this vs target
Context
Handler
.off06
.off("click")
Unbind
Cleanup
❓ Frequently Asked Questions
The click event fires when the user presses and releases the mouse button while the pointer is inside an element. In modern jQuery, bind handlers with .on('click', handler) since version 1.7. The event is sent to any HTML element — buttons, divs, paragraphs, and list items can all receive it.
Use .on('click', handler) for binding. The old .click(handler) shorthand still works but is deprecated — it is a thin wrapper around .on('click'). For unbinding, use .off('click') instead of .unbind('click'). .on() also supports event delegation: .on('click', 'li', fn).
click fires only after mousedown AND mouseup both occur inside the same element — the full press-and-release gesture. mousedown fires when the button is pressed; mouseup when it is released. Use mousedown or mouseup when you do not need the complete click sequence — for example, drag operations or canceling before release.
Call .trigger('click') on the target element: $('#target').trigger('click'). Available since jQuery 1.0, trigger runs bound click handlers and default actions (such as following a link). To trigger handlers without default behavior, use .triggerHandler('click') instead.
Instead of binding to each child, attach one handler on a parent: $('#list').on('click', 'li', fn). jQuery listens on #list and runs fn when a click originates from an li — including items added later via .append(). This is the recommended pattern for dynamic lists and tables.
Inside a handler, this (or $(this)) is the element the handler is bound to — or the matched child when using delegation. event.target is the deepest DOM node that actually received the click. With delegation on #list for li clicks, this is the li that was clicked; event.target might be a span inside that li if the user clicked the span.
Did you know?
jQuery unified event binding in version 1.7 with .on() and .off(), replacing a zoo of shorthand methods like .click(), .bind(), and .live(). The old .click(handler) still works but is deprecated — under the hood it delegates to .on("click"). The separate .click() method without arguments remains valid as shorthand for .trigger("click"), though .trigger("click") is clearer in modern code.