The .focusin() method is jQuery’s legacy shorthand for binding and triggering the focusin event. This tutorial covers .focusin(handler) since 1.0, .focusin(eventData, handler) since 1.4.3, no-argument .focusin() as a trigger, migration to .on("focusin") and .trigger("focusin"), and why the binding form is deprecated since jQuery 3.3. For the modern focusin event API, see the jQuery focusin event tutorial.
01
.focusin(fn)
Bind handler
02
eventData
Since 1.4.3
03
.focusin()
Trigger event
04
.on()
Modern bind
05
.trigger()
Modern fire
06
Deprecated
Since 3.3
Fundamentals
Introduction
Before jQuery 1.7 unified events with .on() and .off(), every common event had a matching shorthand — .focusin(), .focus(), .blur(), and more. The .focusin() method let you react when focus enters an element or any descendant in one call: $("#form").focusin(function(){ ... }). It remains in jQuery 3.x for backward compatibility but is marked deprecated.
Understanding .focusin() matters when reading older parent-form delegation code. The method does two distinct jobs: with a function argument it binds; with no arguments it triggers. Modern jQuery splits those roles — .on("focusin", handler) for binding and .trigger("focusin") for firing.
Concept
Understanding the .focusin() Method
The official jQuery API describes .focusin() as a way to bind an event handler to the focusin event, or trigger that event on an element. When you pass a handler, jQuery registers it on each matched element and calls it when the element or any nested descendant gains focus — the bubbling focusin event that .on("focusin") handles today.
When you call .focusin() with no arguments, jQuery synthetically fires the focusin event on each matched element. Bound handlers run — useful for testing parent-level handlers. To move keyboard focus to an input, use .trigger("focus") instead; the browser fires both focus and focusin automatically.
⚠️
Deprecated since jQuery 3.3
Do not use .focusin(handler) or .focusin(eventData, handler) in new code. Replace them with .on("focusin", handler) or .on("focusin", eventData, handler). Replace no-argument .focusin() with .trigger("focusin"). For bubbling semantics, delegation, and the full modern guide, read the jQuery focusin event tutorial.
Foundation
📝 Syntax
The .focusin() method has three signatures from the official jQuery API. The binding forms are deprecated; the trigger form remains valid but .trigger("focusin") is preferred:
All .focusin() signatures return the original jQuery object for chaining.
Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).
Cheat Sheet
⚡ Quick Reference
Goal
Legacy (.focusin)
Modern replacement
Bind focusin on parent
$("#form").focusin(fn) ⚠
$("#form").on("focusin", fn)
Pass data to handler
$("#form").focusin({ theme: "blue" }, fn) ⚠
$("#form").on("focusin", { theme: "blue" }, fn)
Trigger focusin programmatically
$("#form").focusin()
$("#form").trigger("focusin")
Move keyboard focus to input
$("#login").trigger("focus") — fires focus and focusin
Remove focusin handlers
$("#form").off("focusin")
Delegated filter on inputs
$("#form").on("focusin", "input", fn) — not available via .focusin()
Exit pair (bubbles)
$("#form").on("focusout", "input", fn)
Compare
📋 .focusin() vs .on("focusin") vs .trigger("focusin") vs .off("focusin")
Four related APIs — know which one binds, which one fires, and which one removes handlers.
.focusin()
deprecated
Legacy bind (.focusin(fn)) or trigger (.focusin()) — use modern APIs for new code
.on("focusin")
bind
Modern binding since 1.7 — supports eventData and delegation on dynamic forms
.trigger("focusin")
fire
Programmatically run handlers — clearer than no-arg .focusin()
.off("focusin")
remove
Unbind handlers — pair with .on("focusin") when cleaning up or in SPAs
Hands-On
Examples Gallery
Five examples cover binding, eventData, triggering, migration from .focusin() to .on("focusin"), and method chaining. Use the Try-it links to run each snippet in the browser. Remember: binding with .focusin(handler) is deprecated — these demos show legacy syntax you will encounter in older code.
📚 Binding & Triggering
Legacy .focusin() signatures for binding handlers and firing events programmatically.
Example 1 — Bind Handler on <p> with .focusin(handler)
Official-style legacy pattern — react when focus enters a paragraph or any nested input inside it.
Tab into input inside a <p>
→ "focusin fire" span appears on that paragraph, fades over 1s
Handler on <p> — focusin bubbled up from nested input
Deprecated — prefer .on("focusin", fn) for new code
How It Works
.focusin(fn) on the paragraph catches focus entering any descendant. jQuery routes this to .on("focusin", fn). $(this) is the <p> element when focus bubbles up from the input.
Example 2 — Pass eventData with .focusin(eventData, handler)
Since jQuery 1.4.3, pass a theme object before the handler on a parent form — it arrives as event.data.
Focus any input inside #profile-form
→ all inputs get blue border, #out shows theme
event.data.theme shared via one .focusin() on the form
Modern equivalent: .on("focusin", { theme: "blue" }, fn)
How It Works
Binding .focusin({ theme: "blue" }, fn) on the form passes event.data to the handler whenever focus enters the form or any nested field. Because focusin bubbles, one parent binding covers all inputs.
Example 3 — Trigger Focusin with No-Argument .focusin()
Calling .focusin() without a handler fires the focusin event programmatically on the matched element.
Focus into #target → count increments
Click #fire → $("#target").focusin() → same handler runs
No-arg .focusin() is trigger shorthand — prefer .trigger("focusin")
How It Works
The first .focusin(function(){ ... }) binds a handler on #target. The button calls $("#target").focusin() with no arguments — that synthetically fires focusin. Replace with $("#target").trigger("focusin") for clarity.
📈 Migration & Chaining
Compare legacy and modern APIs, and chain after .focusin(handler).
Example 4 — Migration: .focusin(fn) vs .on("focusin", fn)
Both bind the same focusin event — .on() is the recommended API for new code.
jQuery
$( "#legacy" ).focusin( function() {
$( "#out" ).text( "Legacy: .focusin(function(){ ... }) — deprecated since jQuery 3.3." );
} );
$( "#modern" ).on( "focusin", function() {
$( "#out" ).text( "Modern: .on('focusin', function(){ ... }) — use this for new code." );
} );
Focus into #legacy → legacy deprecation message
Focus into #modern → modern .on("focusin") message
Behavior is identical — only the API name differs
How It Works
Under the hood, .focusin(fn) calls .on("focusin", fn). Migration is a straight rename with no behavior change for simple bindings. The advantage of .on() is delegation — $("#form").on("focusin", "input", fn) — which .focusin() cannot do.
Example 5 — Chaining After .focusin(handler)
.focusin(handler) returns the jQuery object — chain show-hint and highlight handlers on parent forms.
User clicks or tabs into #form
First handler shows #hint text
Second handler adds .active class
Both handlers run in bind order on each focusin
How It Works
Multiple .focusin(fn) calls on the same element stack handlers — all run when focus enters (including descendants). Because each call returns the jQuery object, you can chain them fluently. The same chaining pattern works with .on("focusin", fn).
Applications
🚀 Common Use Cases
Reading legacy code — recognize $("#form").focusin(fn) as equivalent to .on("focusin", fn) in older form scripts.
Parent paragraph handler — legacy code binds $("p").focusin(fn) to react when nested inputs gain focus.
Form container binding — $("#form").focusin(fn) highlights active fields without per-input bindings.
Shared eventData — $("#form").focusin({ theme: "blue" }, fn) passes config to one parent handler.
Chained handlers — stacked .focusin(fn) calls show hints and add .active on the form.
Maintaining WordPress themes — many admin and front-end scripts still use .focusin() — know how to migrate safely.
🧠 How .focusin() Routes Through jQuery
1
You call .focusin()
With a function argument, jQuery treats it as a bind request. With no arguments, it treats it as a trigger request.
dispatch
2
Bind path
.focusin(handler) delegates internally to .on("focusin", handler) — the handler is stored in jQuery’s event system.
.on("focusin")
3
Trigger path
No-arg .focusin() delegates to .trigger("focusin") — bound handlers run when focus enters (including descendants).
.trigger("focusin")
4
✎
jQuery object returned
Both paths return the original collection for chaining — .focusin(fn).addClass("watched") works the same as .on("focusin", fn).addClass("watched").
Important
📝 Notes
Deprecated since jQuery 3.3 — do not use .focusin(handler) or .focusin(eventData, handler) in new code. Use .on("focusin") instead.
Bind with .focusin(handler) since jQuery 1.0; eventData form since 1.4.3.
No-argument .focusin() triggers the event since jQuery 1.0 — prefer .trigger("focusin").
.focusin(handler) binds on matched elements — for selector filtering use .on("focusin", "input", fn).
Native focusinbubbles — that is why parent .focusin(fn) catches nested input focus.
Pair with focusout on the same parent for complete enter/exit tracking.
Remove handlers with .off("focusin") — not by calling .focusin(undefined).
The underlying focusin event is a standard DOM focus event supported in every browser jQuery targets. The .focusin() method itself is a jQuery API — it works in jQuery 1.x, 2.x, and 3.x. Binding via .focusin(handler) is deprecated since 3.3 but still functional; triggering via no-arg .focusin() also remains supported.
✓ jQuery 1.0+
jQuery .focusin() method
Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.3 — use .on('focusin') for new projects. Native equivalent for binding: element.addEventListener('focusin', fn). Use .trigger('focus') to move keyboard 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 jQuery projects. Migrate bindings to .on('focusin') and triggers to .trigger('focusin') when updating parent-form delegation code.
Wrap Up
Conclusion
The jQuery .focusin() method is the legacy shorthand for binding and triggering focusin handlers. Use .focusin(handler) or .focusin(eventData, handler) to bind — both deprecated since jQuery 3.3. Use no-argument .focusin() to trigger — equivalent to .trigger("focusin").
For new code, prefer .on("focusin", fn) for binding and .trigger("focusin") for programmatic firing. When you encounter .focusin() in older form scripts, recognize it, understand it, and migrate when practical. For delegation, focusin, and the complete modern focusin event workflow, continue with the jQuery focusin event tutorial.
Write new form validation with deprecated .focusin(handler)
Assume .focusin() supports delegation — it does not
Confuse .focusin(fn) (bind) with .focusin() (trigger)
Use .unbind("focusin") — it is also deprecated; use .off("focusin")
Copy deprecated patterns from old tutorials without modernizing them
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .focusin()
Legacy bind, modern migrate.
6
Core concepts
.focusin01
.focusin(fn)
Bind
Deprecated
data02
eventData
Since 1.4.3
Handler
()03
.focusin()
Trigger
No args
.on04
.on("focusin")
Modern
Replace
⚡05
.trigger()
Fire
Programmatic
3.306
Deprecated
Since 3.3
Migrate
❓ Frequently Asked Questions
The .focusin() method has two roles. With a handler argument — .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. Both forms have been part of jQuery since 1.0; the binding form 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) or .on('focusin', eventData, handler) instead. The no-argument .focusin() trigger form still works but .trigger('focusin') is clearer and preferred in modern code.
.focusin(handler) registers a callback — it does not fire the event immediately. .focusin() with no arguments triggers the focusin event programmatically on every matched element, the same as .trigger('focusin'). The handler form is deprecated for binding; the no-arg form is a trigger shorthand.
Replace .focusin(fn) with .on('focusin', fn). Replace .focusin(data, fn) with .on('focusin', data, fn). Replace no-arg .focusin() with .trigger('focusin'). Replace .unbind('focusin') cleanup with .off('focusin'). Under the hood, .focusin(handler) delegates to .on('focusin') — migration is a straight rename.
.focus() binds or triggers the non-bubbling focus event on the matched element directly. .focusin() binds or triggers the bubbling focusin event — ideal for parent containers that detect focus on nested inputs. For moving keyboard focus, use .trigger('focus') on the target input; focusin handlers on ancestors run automatically.
Since jQuery 1.4.3, pass an object before the handler — jQuery attaches it to event.data. For example, .focusin({ theme: 'blue' }, fn) on a form lets fn read event.data.theme when any nested input gains focus (bubbles). Modern equivalent: .on('focusin', { theme: 'blue' }, fn).
Did you know?
jQuery unified event binding in version 1.7 with .on() and .off(), replacing shorthand methods like .focusin(), .focus(), and .bind(). The old .focusin(handler) still works but is deprecated since 3.3 — under the hood it delegates to .on("focusin"). The separate no-argument .focusin() remains valid as shorthand for .trigger("focusin"), though .trigger("focusin") is clearer in modern code.