jQuery .trigger() Method

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

What You’ll Learn

The .trigger() method programmatically executes handlers bound with .on(). Use it to simulate clicks, fire custom events, pass runtime data to handlers, and chain UI actions — all without waiting for user input. This tutorial covers official signatures, five worked examples, and comparison with .triggerHandler().

01

Syntax

.trigger(type)

02

Handlers

Runs .on() fns

03

Extra args

[, params]

04

Custom

Any event name

05

Bubbles

Since 1.3

06

Since 1.0

Core API

Introduction

Events usually start with user action — a click, a keypress, a form submit. But your code often needs to fire those same handlers programmatically: auto-submit after validation, simulate a button click from another control, or notify components through a custom event name.

jQuery’s .trigger() method (available since 1.0) runs every handler registered for the given event type on the matched elements, in the same order they would run if the event occurred naturally. Since jQuery 1.3, triggered events bubble up the DOM tree just like real browser events.

Understanding .trigger()

Binding and triggering are two halves of the same pattern. You attach a handler with .on("click", fn); later, .trigger("click") invokes fn without the user clicking. jQuery builds a synthesized event object and passes it as the first argument to each handler.

The second argument to .trigger() lets you pass extra parameters determined at trigger time. This differs from eventData passed to .on() at bind time — both reach the handler, but through different mechanisms and at different stages.

💡
Beginner Tip

To run jQuery handlers without native browser side effects (like following a link or submitting a form), use .triggerHandler() instead. .trigger("submit") may also invoke the browser’s default submit behavior.

📝 Syntax

Two signatures from the official jQuery API:

1. Event type string — .trigger( eventType [, extraParameters ] ) since 1.0

jQuery
.trigger( eventType [, extraParameters ] )
  • eventType — event name such as "click", "submit", or a custom name like "logged".
  • extraParameters — array (or single value since 1.6.2) passed to handlers after the event object.

2. Event object — .trigger( event [, extraParameters ] ) since 1.3

jQuery
var event = jQuery.Event( "submit" );
$( "form" ).first().trigger( event );
if ( event.isDefaultPrevented() ) {
  // Handler called preventDefault()
}

Bind + trigger pattern

jQuery
$( "#foo" ).on( "click", function() {
  alert( $( this ).text() );
});
$( "#foo" ).trigger( "click" );  // runs the handler immediately

Custom event with parameters

jQuery
$( "#foo" ).on( "custom", function( event, param1, param2 ) {
  alert( param1 + "\n" + param2 );
});
$( "#foo" ).trigger( "custom", [ "Custom", "Event" ] );

Return value

  • Returns the original jQuery object for chaining.
  • Handler return values are collected; if any handler returns false, the returned jQuery object reflects that.

⚡ Quick Reference

GoalCode
Trigger click handlers$("#btn").trigger("click")
Pass extra args to handler$("p").trigger("click", ["foo", "bar"])
Fire custom event$("#app").trigger("refresh")
Custom event + data$("#foo").trigger("custom", ["A", "B"])
Trigger with Event object$(form).trigger(jQuery.Event("submit"))
jQuery-only (no native)$("#btn").triggerHandler("click")
Added injQuery 1.0 (Event obj 1.3)

📋 .trigger() vs .triggerHandler() vs shorthand methods

Three ways to programmatically invoke event behavior. Choose based on whether you need bubbling, native actions, or jQuery-only handlers.

.trigger()
Bubbles

Runs handlers + may invoke native behavior

.triggerHandler()
No bubble

First element only, jQuery handlers only

.click()
Shorthand

Bind or trigger click — see click tutorial

.on()
Bind

Attach handlers that .trigger() will run

Examples Gallery

All five examples follow the official jQuery API documentation for .trigger(). Use the Try-it links to fire events and watch handlers run programmatically.

📚 Official API Examples

Five patterns from api.jquery.com/trigger/.

Example 1 — Button #2 Triggers Click on Button #1

Official interactive demo: clicking the second button programmatically triggers the first button’s click handler.

jQuery
$( "button" ).first().on( "click", function() {
  update( $( "span" ).first() );
});

$( "button" ).last().on( "click", function() {
  $( "button" ).first().trigger( "click" );
  update( $( "span" ).last() );
});

function update( j ) {
  var n = parseInt( j.text(), 10 );
  j.text( n + 1 );
}
Try It Yourself

How It Works

.trigger("click") executes bound handlers in registration order. Button #2’s handler chains into Button #1’s logic without simulating a physical click on Button #1.

Example 2 — Trigger a Bound Click Handler on #foo

The canonical bind-then-trigger pattern from the API docs.

jQuery
$( "#foo" ).on( "click", function() {
  alert( $( this ).text() );
});

$( "#foo" ).trigger( "click" );
Try It Yourself

How It Works

Handlers attached with .on() respond identically whether the event is user-generated or triggered in code. Order of execution matches natural event delivery.

Example 3 — Trigger a Custom Event with Parameters

Bind a custom event name and pass an array of values at trigger time.

jQuery
$( "#foo" ).on( "custom", function( event, param1, param2 ) {
  alert( param1 + "\n" + param2 );
});

$( "#foo" ).trigger( "custom", [ "Custom", "Event" ] );
Try It Yourself

How It Works

Custom event names work like browser events for jQuery’s purposes. Extra trigger parameters become handler arguments after event — unlike eventData from .on(), which lives on event.data.

Example 4 — Pass Arbitrary Data on a Standard Click

Official pattern: extra parameters on .trigger() override undefined handler args from normal clicks.

jQuery
$( "p" )
  .on( "click", function( event, a, b ) {
    // Normal click: a and b are undefined
    // trigger below: a is "foo", b is "bar"
    alert( "a=" + a + ", b=" + b );
  } )
  .trigger( "click", [ "foo", "bar" ] );
Try It Yourself

How It Works

extraParameters from .trigger() are determined at fire time. eventData from .on("click", { ... }, fn) is fixed at bind time and appears on event.data instead.

Example 5 — Trigger with a jQuery.Event Object

Create a custom event object, attach properties, trigger it, and inspect isDefaultPrevented().

jQuery
var event = jQuery.Event( "logged" );
event.user = "foo";
event.pass = "bar";

$( "body" ).on( "logged", function( e ) {
  alert( "User: " + e.user + ", Pass: " + e.pass );
  e.preventDefault();
});

$( "body" ).trigger( event );

if ( event.isDefaultPrevented() ) {
  console.log( "Default was prevented" );
}
Try It Yourself

How It Works

Passing an event object gives full control before triggering. Handlers can call preventDefault() or stopPropagation(); the caller inspects the same object afterward.

🚀 Common Use Cases

  • Chained UI actions — one button triggers another element’s click handler.
  • Form workflows — validate in code, then $("form").trigger("submit").
  • Component pub/sub$("#app").trigger("dataLoaded", [payload]) between modules.
  • Testing & demos — fire events in Try-it labs without manual clicks.
  • Auto-initialization — trigger a custom "ready" event after plugin setup.
  • Keyboard shortcuts — map a keypress to $("#save").trigger("click").

🧠 How .trigger() Executes Handlers

1

Build event

jQuery creates or accepts an event object for the requested type and attaches any extra parameters you pass.

Create
2

Run handlers

All matching handlers on the element execute in bind order, receiving the event object plus extra parameters.

Invoke
3

Bubble up

Since jQuery 1.3, the event bubbles through ancestors unless stopped with return false or stopPropagation().

Bubble
4

Native action

Unless prevented, default browser behavior may also run — use .triggerHandler() when you want to skip native side effects.

📝 Notes

  • .trigger() has existed since jQuery 1.0; event object support since 1.3; single-value extraParameters since 1.6.2.
  • Triggered events bubble (since 1.3) but do not perfectly replicate every detail of user-generated events.
  • extraParameters to .trigger() differ from eventData to .on() — bind-time vs trigger-time data.
  • On plain objects and DOM nodes, if the event name matches a property (e.g. onclick), jQuery may invoke it unless preventDefault() is called.
  • For objects with a length property that are not array-like, wrap in an array: .trigger("evt", [{ length: 1 }]).
  • .trigger() works on plain JavaScript objects wrapped in jQuery for pub/sub-style messaging.

Browser Support

.trigger() is a jQuery method available since jQuery 1.0 in all jQuery 1.x, 2.x, and 3.x releases. It works in every browser your jQuery version supports. Native equivalent: element.dispatchEvent(new Event('click')) — but without jQuery's handler registry, extra parameters, or custom event conveniences.

jQuery 1.0+

jQuery .trigger()

Supported in jQuery 1.0+ across all modern browsers and IE with supported jQuery builds. The standard way to programmatically fire jQuery-bound events.

100% Core jQuery API
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
.trigger() Universal

Bottom line: Use .trigger() to run .on() handlers from code. Pass extra parameters when handlers need runtime data. Prefer .triggerHandler() when native browser actions must not run.

Conclusion

jQuery .trigger() closes the loop with .on(): bind handlers to react to events, then fire those same handlers from code when your application logic requires it. Custom events, extra parameters, and jQuery.Event objects make it flexible for real-world UI orchestration.

Remember the distinction between trigger-time parameters and bind-time eventData, and reach for .triggerHandler() when you need jQuery-only behavior. The click event tutorial shows .trigger("click") in a full mouse-event context.

💡 Best Practices

✅ Do

  • Use custom event names for decoupled component communication
  • Pass runtime data via .trigger(type, [a, b]) when needed at fire time
  • Use jQuery.Event() when you need to inspect isDefaultPrevented() after
  • Prefer .triggerHandler() to avoid unwanted native submit/click behavior
  • Keep handler logic in named functions reusable by both user events and triggers

❌ Don’t

  • Assume .trigger() perfectly simulates real user interaction for all tests
  • Confuse .trigger() extra params with .on() eventData
  • Trigger submit on forms without understanding native submit may also run
  • Create infinite trigger loops (A triggers B triggers A)
  • Trigger events on elements with no bound handlers and expect side effects

Key Takeaways

Knowledge Unlocked

Six things to remember about .trigger()

Fire events from code.

6
Core concepts
[ ] 02

Extra args

At trigger time.

Data
custom 03

Custom

Any event name.

Pub/sub
04

Bubbles

Since 1.3.

DOM
Event 05

jQuery.Event

Full control.

Advanced
H 06

Handler

No native fx.

Alt API

❓ Frequently Asked Questions

.trigger() executes all handlers attached with .on() (or shortcut methods) for the given event type on the matched elements. It simulates an event activation programmatically — useful for testing, chaining actions, or firing custom events without user input.
.click() and .submit() are shorthand methods that may also invoke native browser behavior. .trigger('click') runs jQuery handlers and can bubble up the DOM (since 1.3). Use .triggerHandler() if you only want jQuery handlers without native side effects.
Pass an array as the second argument: .trigger('click', ['foo', 'bar']). Extra values arrive as parameters after the event object in the handler: function(event, a, b). This is different from eventData passed to .on() at bind time.
.trigger() fires handlers on matched elements and bubbles (like a real event). .triggerHandler() runs handlers on only the first matched element, does not bubble, and does not invoke native default actions — ideal when you want jQuery-only behavior.
Yes. Bind with .on('myEvent', fn) and fire with .trigger('myEvent') or .trigger('myEvent', [extraData]). Custom events are useful for pub/sub patterns between components.
No. .trigger() creates a synthesized jQuery event object and runs handlers in the same order as a natural event, but it does not perfectly replicate every browser detail of a real user interaction. For testing native behavior, user actions or integration tests may be needed.
Did you know?

Before jQuery 1.3, .trigger() did not bubble triggered events up the DOM. That change made programmatic events behave much closer to real user events — delegated handlers on parent elements now respond to .trigger() on children, just as they do to actual clicks.

Next: .triggerHandler() Method

Learn to fire jQuery handlers without bubbling or native side effects.

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