jQuery .trigger() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Event Handler

Definition

.trigger(eventType [, extraParameters]) executes handlers (and related behaviors) for an event on the matched elements (since 1.0). Since 1.3 you can also pass a jQuery.Event object; triggered events bubble.

Syntax

Start with these common calls. Keep them short and readable.

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

$("#foo").trigger("click"); // run that handler now

// Custom event + extra args
$("#foo").on("custom", function (event, a, b) {
  alert(a + " / " + b);
});
$("#foo").trigger("custom", ["Custom", "Event"]);
CallWhat it does
.trigger(eventType [, extra])Fire by event name string
.trigger(event [, extra])Fire a jQuery.Event object

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
eventType [Used in .trigger(eventType [, extra]). Fire by event name string
extra]Used in .trigger(eventType [, extra]). Fire by event name string
event [Used in .trigger(event [, extra]). Fire a jQuery.Event object

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Trigger Another Click

Button #2 programmatically fires Button #1’s click handlers.

jQuery
$("#btn1").on("click", function () {
  $("#out").text("Button #1 handler ran");
});

$("#btn2").on("click", function () {
  $("#btn1").trigger("click");
  $("#out").append(" · Button #2 also ran");
});
Try It Yourself

How It Works

  1. Bind. #1 has its own click handler.
  2. Trigger. #2 calls $("#btn1").trigger("click").
  3. Reuse. #1’s handlers run without a physical click on #1.

Example 2 — Extra Parameters

Pass fire-time data after the event object.

jQuery
$("p").on("click", function (event, a, b) {
  $("#out").text(String(a) + " / " + String(b));
});

$("p").trigger("click", ["foo", "bar"]);
Try It Yourself

How It Works

  1. Handler. Declares parameters after event.
  2. Trigger. Second argument supplies those values.
  3. Normal click. A real user click leaves a / b undefined.

Example 3 — Custom Event

Invent an event name and fire it with payload data.

jQuery
$("#target").on("myCustomEvent", function (event, myName) {
  $(this).text(myName + ", hi there!");
});

$("#fire").on("click", function () {
  $("#target").trigger("myCustomEvent", ["John"]);
});
Try It Yourself

How It Works

  1. Bind. Listen for myCustomEvent with .on().
  2. Fire. Button calls .trigger("myCustomEvent", …).
  3. Args. Extra values arrive after event.

Frequently Asked Questions

.trigger() runs handlers attached for an event type on the matched elements. It synthesizes an event (and can bubble since 1.3) so you can fire clicks, submits, or custom events without a real user action.
.trigger() affects all matched elements, bubbles, and may invoke native behaviors. .triggerHandler() runs handlers on only the first matched element, does not bubble, and skips native default actions.
Pass extra parameters as the second argument: .trigger("custom", ["a", "b"]). They arrive after the event object in the handler. That is different from eventData given to .on() at bind time.
Yes. Bind with .on("myEvent", fn) and fire with .trigger("myEvent") or .trigger("myEvent", [extra]). Useful for component messaging without native DOM event types.
No. It runs jQuery handlers in order with a synthesized event object, but it does not perfectly replicate every browser detail of a natural user event.
When you want jQuery handlers only — no bubbling and no native default (for example, avoiding a real form submit or focus side effects).

Next: .triggerHandler() Method

See the no-bubble, no-default alternative to .trigger().

.triggerHandler() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

8 people found this page helpful