jQuery Click Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Mouse events

What You’ll Learn

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

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 click event (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.

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.

📝 Syntax

The modern jQuery API for the click event has two main forms — binding a handler and triggering the event:

1. Bind a handler — .on("click" [, eventData ], handler) (since 1.7)

jQuery
.on( "click" [, eventData ], handler )
  • eventData — optional object passed to the handler as event.data.
  • handler — function called each time click fires: function( event ) { ... }.

2. Event delegation — .on("click", selector, handler)

jQuery
$( "#list" ).on( "click", "li", function( event ) {
  // runs when any li inside #list is clicked
} );

3. Trigger the event — .trigger("click") (since 1.0)

jQuery
.trigger( "click" )
  • Runs bound click handlers and default browser actions (e.g. following a link).
  • Use .triggerHandler("click") to run handlers without default actions.

4. Unbind — .off("click" [, selector] [, handler])

jQuery
$( "#target" ).off( "click" );           // remove all click handlers
$( "#list" ).off( "click", "li", fn );   // remove delegated handler

Official jQuery API examples

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

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

Return value

  • .on() and .trigger() return the original jQuery object for chaining.
  • Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).

⚡ Quick Reference

GoalCode
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)

📋 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

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.

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

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.

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

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

How It Works

.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.

jQuery
$( "p" ).on( "click", function() {
  $( this ).slideUp();
} );
Try It Yourself

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.

jQuery
$( "p" ).trigger( "click" );
Try It Yourself

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.

jQuery
$( "#list" ).on( "click", "li", function() {
  $( this ).toggleClass( "done" );
} );
Try It Yourself

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.

🚀 Common Use Cases

  • Button actions$("#submit").on("click", fn) to validate forms or send AJAX requests.
  • Dismissible alerts$(".alert .close").on("click", function(){ $(this).parent().fadeOut(); }).
  • Tab navigation — click handlers swap visible panels and update active classes.
  • Todo lists — delegated $("#tasks").on("click", "li", fn) for items added at runtime.
  • Proxy triggers$("#shortcut").on("click", function(){ $("#real-btn").trigger("click"); }).
  • 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.

📝 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".

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 Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
click Universal

Bottom line: Safe in any jQuery project. Prefer .on('click') over deprecated .click() for binding. Use delegation for dynamic content.

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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Six things to remember about the click event

Bind, trigger, delegate.

6
Core concepts
02

.trigger()

Fire

Programmatic
↓↑ 03

Down + up

Sequence

Behavior
li 04

Delegate

Dynamic

Pattern
this 05

this vs target

Context

Handler
.off 06

.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.

Next: .click() Method

Learn the deprecated shorthand — and how to migrate to .on("click").

.click() tutorial →

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.

6 people found this page helpful