.focusin() is jQuery’s legacy shorthand for binding or triggering the bubbling focusin event — when an element or a descendant gains focus. Binding is deprecated since 3.3; modern code uses .on("focusin") / .trigger("focusin").
Remember
// Legacy (still works; bind form deprecated since 3.3)
$("p").focusin(function () {
// this <p> or a nested input gained focus
});
// Modern replacements
$("p").on("focusin", handler); // bind
$("p").trigger("focusin"); // fire handlers
// Better for dynamic forms (delegation)
$("#form").on("focusin", "input", handler);
Click #fire → no-arg .focusin() runs
Bound handler updates #out
Keyboard focus may stay on the button
How It Works
Bind. The handler is registered on #box.
Click. No-arg .focusin() triggers the event.
Handlers. Bound focusin callbacks run immediately.
Caret. To move focus, use .trigger("focus") on an input.
Example 4 — Migrate to .on("focusin")
Both bind the same event — .on() is the recommended API for new code.
jQuery
$("#legacy").focusin(function () {
$("#out").text("Legacy: .focusin(fn) — deprecated since 3.3.");
});
$("#modern").on("focusin", function () {
$("#out").text("Modern: .on('focusin', fn) — use this for new code.");
});
Rule. Use focusin (or .on("focusin")) for parents.
Edge Cases & Pitfalls
Watch for these when reading or migrating legacy .focusin() code.
deprecated
Bind form deprecated since 3.3
Still works in jQuery 3.x, but new code should use .on("focusin").
delegation
No built-in delegation
.focusin(fn) cannot target future elements. Use $("#form").on("focusin", "input", fn).
trigger
No-arg .focusin() ≠ move caret
It runs handlers. To move keyboard focus, call .trigger("focus") on a visible input.
bind vs trigger
.focusin(fn) ≠ .focusin()
With a function it binds; with no args it triggers. Always check the parentheses.
Compatibility
Browser Support
The underlying focusin event is a standard DOM event with bubbling. The .focusin() method is a jQuery API available since 1.0 (eventData since 1.4.3). Binding via .focusin(handler) is deprecated since 3.3 but still functional in jQuery 3.x.
✓ Deprecated · jQuery 3.3
jQuery .focusin()
Works in jQuery 1.x–3.x. Prefer .on('focusin') / .trigger('focusin') for new projects. Use parents to catch nested focus.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.focusin()Legacy API
Bottom line: Safe in legacy projects. Migrate bindings to .on('focusin') and triggers to .trigger('focusin') when you touch form scripts.
Analysis
Performance Notes
Approach
Cost
Best for
One .on("focusin") on a form
Cheap
Many nested fields
Delegated .on("focusin", "input", fn)
Cheap
Dynamic / AJAX fields
Heavy work on every focusin
Expensive
Avoid — keep handlers light
The shorthand and .on("focusin") cost the same for a single bind. Prefer .on() for clarity and delegation. Keep the callback light.
Remember
Key Takeaways
Role: legacy bind/trigger for bubbling focusin.
Migrate:.on("focusin", fn) and .trigger("focusin").
Delegation: only available via .on("focusin", selector, fn).
One line:.focusin() is deprecated sugar for .on("focusin") / .trigger("focusin") — migrate when you touch the file.
Frequently Asked Questions
The .focusin() method has two roles. With a handler — .focusin(handler) or .focusin(eventData, handler) — it binds a function that runs when the matched element or any descendant gains focus (bubbles). With no arguments — .focusin() — it triggers the focusin event on each matched element. Binding has been part of jQuery since 1.0 and is deprecated since 3.3.
Yes. The binding signatures .focusin(handler) and .focusin(eventData, handler) are deprecated since jQuery 3.3. Use .on("focusin", handler) instead. The no-argument .focusin() trigger still works, but .trigger("focusin") is clearer. Legacy code continues to run in jQuery 3.x.
.focusin(handler) registers a callback and does not fire immediately. .focusin() with no arguments triggers the focusin event — the same as .trigger("focusin"). Check whether parentheses contain a function before reading legacy code.
Replace .focusin(fn) with .on("focusin", fn). Replace .focusin(data, fn) with .on("focusin", data, fn). Replace no-arg .focusin() with .trigger("focusin"). Cleanup with .off("focusin"). Under the hood, .focusin(handler) already delegates to .on("focusin").
.focus() binds or triggers the non-bubbling focus event on the matched element. .focusin() binds or triggers the bubbling focusin event — better for parent containers that detect focus on nested inputs. To move keyboard focus, use .trigger("focus") on the target input.
No. Direct .focusin(fn) only binds to elements that already match. For dynamic fields, use .on("focusin", "input", fn) on a parent. That is one reason to prefer .on() over the shorthand.