jQuery .triggerHandler() Method

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

Definition

.triggerHandler() (since jQuery 1.2) runs handlers bound with jQuery for an event type on the first matched element. It is like .trigger(), but without bubbling, without native default actions, and with a handler return value instead of chaining.

Syntax

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

jQuery
$el.triggerHandler("click");                 // first element only
$el.triggerHandler("check", ["extra"]);      // + extra args
var result = $el.triggerHandler("validate"); // last handler return value

// vs .trigger():
// · no DOM bubbling
// · no native .focus() / .submit() side effects
// · does not return the jQuery object
CallWhat it does
.triggerHandler()Learn jQuery .triggerHandler(): run handlers without bubbling or native side effects since 1.2, capture return values, affect the first element only, and compare with .trigger().

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

Parameters

ParameterDescription
Step 1Attach a handler with .on("event", fn) (or custom event name).
Step 2Call .triggerHandler("event") on the element (first match only).
Step 3jQuery runs direct handlers on that element — nothing bubbles up.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Focus: .trigger() vs .triggerHandler()

Official idea: both run the jQuery focus handler; only .trigger() may native-focus.

jQuery
$("input").on("focus", function () {
  $("#log").text("Focused!");
});

$("#old").on("click", function () {
  $("input").trigger("focus");        // handler + may native-focus
});

$("#new").on("click", function () {
  $("input").triggerHandler("focus"); // handler only
});
Try It Yourself

How It Works

  1. Bind. A jQuery focus handler updates the log.
  2. trigger. Runs handlers and may call the browser’s focus action.
  3. triggerHandler. Runs the same handlers without native focus.

Example 2 — Capture a Handler’s Return Value

Unlike .trigger(), you can read what the handler returned.

jQuery
$("#score").on("check", function () {
  var val = parseInt($(this).text(), 10);
  return val >= 50 ? "pass" : "fail";
});

$("#run").on("click", function () {
  var result = $("#score").triggerHandler("check");
  $("#log").text("Return value: " + result);
});
Try It Yourself

How It Works

  1. Custom event. check is a name you invent.
  2. Return. The handler returns "pass" or "fail".
  3. Capture. triggerHandler gives that value back to the caller.

Example 3 — First Matched Element Only

.trigger() hits every match; .triggerHandler() hits only the first.

jQuery
$("button.item").on("click", function () {
  $("#log").append($(this).text() + " ");
});

$("#trigger-all").on("click", function () {
  $("button.item").trigger("click");           // all three
});

$("#trigger-first").on("click", function () {
  $("button.item").triggerHandler("click");    // Item 1 only
});
Try It Yourself

How It Works

  1. Set. Three buttons share the same click handler.
  2. trigger. Runs the handler on every matched button.
  3. triggerHandler. Stops after the first match.

Frequently Asked Questions

.triggerHandler() executes jQuery handlers for an event on the first matched element only. Unlike .trigger(), it does not bubble, does not invoke native defaults (like form .submit()), and returns the last handler’s return value instead of the jQuery object.
.trigger() runs on all matched elements, bubbles, may invoke native behavior, and returns the jQuery object for chaining. .triggerHandler() affects only the first element, never bubbles, skips native side effects, and returns whatever the last executed handler returned (or undefined).
Use it when you only need jQuery handlers — without submitting a form, natively focusing an input, or firing parent handlers. Also use it when you need the handler’s return value for validation or branching.
No. It returns the value from the last handler that ran. If no handlers fire, it returns undefined. Example: var ok = $('#field').triggerHandler('validate') === true.
By design. To run handlers on every match, loop with .each() and call .triggerHandler() per element, or use .trigger() instead.
Yes. Same as .trigger(): .triggerHandler('custom', ['arg1', 'arg2']). Extra values arrive after the event object in the handler.

Next: .off() Method

Remove handlers attached with .on() — the modern unbind API.

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

10 people found this page helpful