jQuery .click() Method

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

What You’ll Learn

The .click() method is jQuery’s legacy shorthand for binding and triggering the click event. This tutorial covers .click(handler) since 1.0, .click(eventData, handler) since 1.4.3, no-argument .click() as a trigger, migration to .on("click") and .trigger("click"), and why the binding form is deprecated since jQuery 3.3. For the modern click event API, see the jQuery click event tutorial.

01

.click(fn)

Bind handler

02

eventData

Since 1.4.3

03

.click()

Trigger event

04

.on()

Modern bind

05

.trigger()

Modern fire

06

Deprecated

Since 3.3

Introduction

Before jQuery 1.7 unified events with .on() and .off(), every common event had a matching shorthand — .click(), .mouseover(), .keydown(), and dozens more. The .click() method let you bind a handler in one short call: $("#btn").click(function(){ ... }). It remains in jQuery 3.x for backward compatibility but is marked deprecated.

Understanding .click() matters when reading older tutorials, Stack Overflow answers, and legacy codebases. The method does two distinct jobs: with a function argument it binds; with no arguments it triggers. Modern jQuery splits those roles explicitly — .on("click", handler) for binding and .trigger("click") for firing. This page documents the shorthand API and shows how to migrate.

Understanding the .click() Method

The official jQuery API describes .click() as a way to bind an event handler to the click event, or trigger that event on an element. When you pass a handler, jQuery registers it on each matched element and calls it when the user completes a full press-and-release click inside that element — the same click event that .on("click") handles today.

When you call .click() with no arguments, jQuery synthetically fires the click event on each matched element. Bound handlers run, and default browser actions execute — for example, a link may navigate. This trigger behavior is equivalent to .trigger("click").

⚠️
Deprecated since jQuery 3.3

Do not use .click(handler) or .click(eventData, handler) in new code. Replace them with .on("click", handler) or .on("click", eventData, handler). Replace no-argument .click() with .trigger("click"). For delegation, event objects, and the full modern click event guide, read the jQuery click event tutorial.

📝 Syntax

The .click() method has three signatures from the official jQuery API. The binding forms are deprecated; the trigger form remains valid but .trigger("click") is preferred:

1. Bind a handler — .click( handler ) (since 1.0, deprecated 3.3)

jQuery
.click( handler )
  • handler — function executed each time click fires: function( event ) { ... }.
  • Returns the jQuery object for chaining.
  • Modern replacement: .on( "click", handler ).

2. Bind with eventData — .click( [eventData], handler ) (since 1.4.3, deprecated 3.3)

jQuery
.click( [eventData], handler )
  • eventData — optional object available in the handler as event.data.
  • Modern replacement: .on( "click", eventData, handler ).

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

jQuery
.click()
  • No arguments — triggers click on every matched element.
  • Runs bound handlers and default browser actions.
  • Preferred replacement: .trigger( "click" ).

Official jQuery API migration note

jQuery
// Deprecated binding
$( "#target" ).click( function() {
  alert( "Handler for `click` called." );
} );

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

// Deprecated trigger
$( "#target" ).click();

// Modern trigger
$( "#target" ).trigger( "click" );

Return value

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

⚡ Quick Reference

GoalLegacy (.click)Modern replacement
Bind click handler$("#btn").click(fn)$("#btn").on("click", fn)
Pass data to handler$("#btn").click({ id: 1 }, fn)$("#btn").on("click", { id: 1 }, fn)
Trigger click programmatically$("#target").click()$("#target").trigger("click")
Trigger all matched elements$("p").click()$("p").trigger("click")
Remove click handlers$("#btn").off("click")$("#btn").off("click")
Delegated click on children$("#list").on("click", "li", fn) — not available via .click()
One-time click$("#btn").one("click", fn) — use .one(), not .click()

📋 .click() vs .on("click") vs .trigger("click") vs .off("click")

Four related APIs — know which one binds, which one fires, and which one removes handlers.

.click()
deprecated

Legacy bind (.click(fn)) or trigger (.click()) — use modern APIs for new code

.on("click")
bind

Modern binding since 1.7 — supports eventData and delegation on dynamic content

.trigger("click")
fire

Programmatically run handlers and defaults — clearer than no-arg .click()

.off("click")
remove

Unbind handlers — pair with .on("click") when cleaning up or in SPAs

Examples Gallery

Five examples cover binding, eventData, triggering, migration from .click() to .on("click"), and method chaining. Use the Try-it links to run each snippet in the browser. Remember: binding with .click(handler) is deprecated — these demos show legacy syntax you will encounter in older code.

📚 Binding & Triggering

Legacy .click() signatures for binding handlers and firing events programmatically.

Example 1 — Bind Handler with .click(handler)

The canonical legacy pattern — attach a function that runs when the user clicks the element.

jQuery
$( "#target" ).click( function() {
  $( "#out" ).text( "Handler ran via .click(function(){ ... })." );
} );
Try It Yourself

How It Works

.click(fn) registers the function on the element. jQuery internally routes this to .on("click", fn). The handler runs once per completed click — mousedown and mouseup both occurred inside #target.

Example 2 — Pass eventData with .click(eventData, handler)

Since jQuery 1.4.3, pass an object before the handler — it arrives as event.data.

jQuery
$( ".action" ).click( { role: "admin" }, function( event ) {
  var id = $( this ).data( "id" );
  $( "#out" ).text(
    "Action: " + id + " | eventData.role: " + event.data.role
  );
} );
Try It Yourself

How It Works

jQuery stores the { role: "admin" } object and injects it into event.data when any matched .action button is clicked. Use $(this).data("id") for per-element attributes. Modern equivalent: .on("click", { role: "admin" }, fn).

Example 3 — Trigger Click with No-Argument .click()

Calling .click() without a handler fires the click event programmatically.

jQuery
var count = 0;

$( "#target" ).click( function() {
  count++;
  $( "#out" ).text( "Target handler fired (count: " + count + ")" );
} );

$( "#fire" ).click( function() {
  $( "#target" ).click();
} );
Try It Yourself

How It Works

The first .click(function(){ ... }) binds a handler on #target. The second binds on #fire and calls $("#target").click() with no arguments — that synthetically fires the click event. Replace with $("#target").trigger("click") for clarity.

📈 Migration & Chaining

Compare legacy and modern APIs, and chain after .click(handler).

Example 4 — Migration: .click(fn) vs .on("click", fn)

Both bind the same click event — .on() is the recommended API for new code.

jQuery
$( "#legacy" ).click( function() {
  $( "#out" ).text( "Legacy: .click(function(){ ... }) — deprecated since jQuery 3.3." );
} );

$( "#modern" ).on( "click", function() {
  $( "#out" ).text( "Modern: .on('click', function(){ ... }) — use this for new code." );
} );
Try It Yourself

How It Works

Under the hood, .click(fn) calls .on("click", fn). Migration is a straight rename with no behavior change for simple bindings. The advantage of .on() is delegation — $("#list").on("click", "li", fn) — which .click() cannot do.

Example 5 — Chaining After .click(handler)

.click(handler) returns the jQuery object — chain further methods immediately.

jQuery
$( "#btn" )
  .click( function() {
    $( "#out" ).text( "Clicked — active class toggled via chained .toggleClass()." );
  } )
  .click( function() {
    $( this ).toggleClass( "active" );
  } );
Try It Yourself

How It Works

Multiple .click(fn) calls on the same element stack handlers — all run on each click. Because each call returns the jQuery object, you can chain them fluently. The same chaining pattern works with .on("click", fn).

🚀 Common Use Cases

  • Reading legacy code — recognize $("#btn").click(fn) as equivalent to .on("click", fn) when maintaining older projects.
  • Quick prototypes — older tutorials and snippets still use .click(); know how to modernize them before shipping.
  • Proxy triggers$("#shortcut").click(function(){ $("#real-btn").click(); }) — replace inner no-arg .click() with .trigger("click").
  • Shared eventData$(".star").click({ rating: 5 }, fn) passes metadata without closures — migrate to .on("click", { rating: 5 }, fn).
  • Stacked handlers — multiple .click(fn) calls on one element run in registration order — same as multiple .on("click", fn) calls.
  • Automated testing — test suites may call .click() to simulate user clicks — consider .trigger("click") for explicit intent.

🧠 How .click() Routes Through jQuery

1

You call .click()

With a function argument, jQuery treats it as a bind request. With no arguments, it treats it as a trigger request.

dispatch
2

Bind path

.click(handler) delegates internally to .on("click", handler) — the handler is stored in jQuery’s event system.

.on("click")
3

Trigger path

No-arg .click() delegates to .trigger("click") — bound handlers run and defaults execute.

.trigger("click")
4

jQuery object returned

Both paths return the original collection for chaining — .click(fn).addClass("ready") works the same as .on("click", fn).addClass("ready").

📝 Notes

  • Deprecated since jQuery 3.3 — do not use .click(handler) or .click(eventData, handler) in new code. Use .on("click") instead.
  • Bind with .click(handler) since jQuery 1.0; eventData form since 1.4.3.
  • No-argument .click() triggers the event since jQuery 1.0 — prefer .trigger("click").
  • .click() does not support event delegation — use .on("click", selector, fn) for dynamic lists.
  • Remove handlers with .off("click") — not by calling .click(undefined).
  • Legacy code using .click() still runs in jQuery 3.x — migrate when you refactor those files.
  • For the full modern click event guide — delegation, event.target, and comparison with mousedown — see the jQuery click event tutorial.

Browser Support

The underlying click event is a standard DOM event supported in every browser jQuery targets. The .click() method itself is a jQuery API — it works in jQuery 1.x, 2.x, and 3.x. Binding via .click(handler) is deprecated since 3.3 but still functional; triggering via no-arg .click() also remains supported.

jQuery 1.0+

jQuery .click() method

Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.3 — use .on('click') for new projects. Native equivalent for binding: element.addEventListener('click', fn). Native equivalent for trigger: element.click() or dispatchEvent.

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() Legacy API

Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('click') and triggers to .trigger('click') when updating code.

Conclusion

The jQuery .click() method is the legacy shorthand for binding and triggering click handlers. Use .click(handler) or .click(eventData, handler) to bind — both deprecated since jQuery 3.3. Use no-argument .click() to trigger — equivalent to .trigger("click").

For new code, prefer .on("click", fn) for binding and .trigger("click") for programmatic firing. When you encounter .click() in older projects, recognize it, understand it, and migrate when practical. For delegation, event objects, and the complete modern click event workflow, continue with the jQuery click event tutorial.

💡 Best Practices

✅ Do

  • Use .on("click", handler) for all new click bindings
  • Use .trigger("click") instead of no-arg .click()
  • Migrate .click(fn) to .on("click", fn) when refactoring legacy files
  • Use .off("click") to remove handlers cleanly
  • Read the modern click event tutorial for delegation patterns

❌ Don’t

  • Write new code with deprecated .click(handler)
  • Assume .click() supports delegation — it does not
  • Confuse .click(fn) (bind) with .click() (trigger)
  • Use .unbind("click") — it is also deprecated; use .off("click")
  • Copy deprecated patterns from old tutorials without modernizing them

Key Takeaways

Knowledge Unlocked

Six things to remember about .click()

Legacy bind, modern migrate.

6
Core concepts
data 02

eventData

Since 1.4.3

Handler
() 03

.click()

Trigger

No args
.on 04

.on("click")

Modern

Replace
05

.trigger()

Fire

Programmatic
3.3 06

Deprecated

Since 3.3

Migrate

❓ Frequently Asked Questions

The .click() method has two roles. With a handler argument — .click(handler) or .click(eventData, handler) — it binds a function that runs when the user clicks the matched element. With no arguments — .click() — it triggers the click event on each matched element, running bound handlers and default browser actions. Both forms have been part of jQuery since 1.0; the binding form is deprecated since 3.3.
Yes — the binding signatures .click(handler) and .click(eventData, handler) are deprecated since jQuery 3.3. Use .on('click', handler) or .on('click', eventData, handler) instead. The no-argument .click() trigger form still works but .trigger('click') is clearer and preferred in modern code. Existing legacy code continues to run in jQuery 3.x; migrate when you touch those files.
.click(handler) registers a callback — it does not fire the event immediately. .click() with no arguments triggers the click event programmatically on every matched element, the same as .trigger('click'). The handler form is deprecated for binding; the no-arg form is a trigger shorthand. Always check whether parentheses contain a function before reading legacy jQuery code.
Replace .click(fn) with .on('click', fn). Replace .click(data, fn) with .on('click', data, fn). Replace no-arg .click() with .trigger('click'). Replace .unbind('click') or .click(undefined) cleanup with .off('click'). Under the hood, .click(handler) already delegates to .on('click') — migration is a straight rename with no behavior change for simple bindings.
Yes. jQuery 3.x keeps .click() for backward compatibility with jQuery 1.x and 2.x codebases. It still binds and triggers correctly. The API docs mark it deprecated to steer new projects toward .on() and .trigger(). Do not use .click(handler) in new code — prefer the modern API covered in the jQuery click event tutorial.
Since jQuery 1.4.3, you can pass an object as the first argument before the handler. jQuery attaches it to event.data inside the callback — for example, .click({ role: 'admin' }, fn) lets fn read event.data.role. This avoids closures when the same handler serves multiple elements. The modern equivalent is .on('click', { role: 'admin' }, fn).
Did you know?

jQuery 1.7 replaced an entire family of event shorthand methods — .click(), .bind(), .live(), and others — with the unified .on() and .off() API. The old methods were kept for compatibility but marked deprecated in stages: .live() in 1.7, .bind() in 1.7, and .click(handler) in 3.3. Under the hood, .click(fn) has always been a thin wrapper around .on("click", fn) — so migrating is often a one-line rename with no runtime behavior change.

Next: .toggle() Click Handlers

Learn the removed legacy API that cycled alternating click handlers.

.toggle() 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