.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
Call
What 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
Parameter
Description
Step 1
Attach a handler with .on("event", fn) (or custom event name).
Step 2
Call .triggerHandler("event") on the element (first match only).
Step 3
jQuery runs direct handlers on that element — nothing bubbles up.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefined
Getters 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
});
Both buttons → "Focused!" in the log
.trigger("focus") → input may also receive real browser focus
.triggerHandler("focus") → handlers only, caret may stay put
How It Works
Bind. A jQuery focus handler updates the log.
trigger. Runs handlers and may call the browser’s focus action.
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);
});
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
});
trigger. Runs the handler on every matched button.
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.