The .mouseenter() method is jQuery’s legacy shorthand for binding and triggering the mouseenter event. This tutorial covers .mouseenter(handler) since 1.0, .mouseenter(eventData, handler) since 1.4.3, no-argument .mouseenter() as a trigger, migration to .on("mouseenter") and .trigger("mouseenter"), and why the binding form is deprecated since jQuery 3.3. For the modern mouseenter event API, see the jQuery mouseenter event tutorial.
01
.mouseenter(fn)
Bind handler
02
eventData
Since 1.4.3
03
.mouseenter()
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 — .click(), .mouseenter(), .keydown(), and dozens more. The .mouseenter() method let you bind a hover-enter handler in one short call: $("#menu").mouseenter(function(){ ... }). It remains in jQuery 3.x for backward compatibility but is marked deprecated.
Understanding .mouseenter() matters when reading older dropdown menus, tooltip plugins, and legacy tutorials. The method does two distinct jobs: with a function argument it binds; with no arguments it triggers. Modern jQuery splits those roles explicitly — .on("mouseenter", handler) for binding and .trigger("mouseenter") for firing. This page documents the shorthand API and shows how to migrate.
Concept
Understanding the .mouseenter() Method
The official jQuery API describes .mouseenter() as a way to bind an event handler to the mouseenter 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 pointer enters that element — without re-firing when moving over nested children, unlike mouseover.
When you call .mouseenter() with no arguments, jQuery synthetically fires the mouseenter event on each matched element. Bound handlers run immediately. This trigger behavior is equivalent to .trigger("mouseenter").
⚠️
Deprecated since jQuery 3.3
Do not use .mouseenter(handler) or .mouseenter(eventData, handler) in new code. Replace them with .on("mouseenter", handler) or .on("mouseenter", eventData, handler). Replace no-argument .mouseenter() with .trigger("mouseenter"). For comparison with mouseover, delegation, and pairing with mouseleave, read the jQuery mouseenter event tutorial.
Foundation
📝 Syntax
The .mouseenter() method has three signatures from the official jQuery API. The binding forms are deprecated; the trigger form remains valid but .trigger("mouseenter") is preferred:
All .mouseenter() 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 (.mouseenter)
Modern replacement
Bind mouseenter handler
$("#box").mouseenter(fn) ⚠
$("#box").on("mouseenter", fn)
Pass data to handler
$("#box").mouseenter({ id: 1 }, fn) ⚠
$("#box").on("mouseenter", { id: 1 }, fn)
Pair enter and leave
.on("mouseenter", in).on("mouseleave", out) — not via single .mouseenter()
Trigger mouseenter programmatically
$("#outer").mouseenter()
$("#outer").trigger("mouseenter")
Remove mouseenter handlers
$("#box").off("mouseenter")
Delegated mouseenter on children
$("#menu").on("mouseenter", "li", fn) — not available via .mouseenter()
Both enter + leave (legacy)
.hover(fnIn, fnOut) — also deprecated; use .on("mouseenter") / .on("mouseleave")
Compare
📋 .mouseenter() vs .on("mouseenter") vs .trigger("mouseenter") vs .hover()
Four related APIs — know which one binds, which one fires, and which one covers both enter and leave.
.mouseenter()
deprecated
Legacy bind (.mouseenter(fn)) or trigger (.mouseenter()) — use modern APIs for new code
.on("mouseenter")
bind
Modern binding since 1.7 — supports eventData and delegation on dynamic menus
.trigger("mouseenter")
fire
Programmatically run handlers — clearer than no-arg .mouseenter()
.hover()
enter+leave
Deprecated shorthand for mouseenter + mouseleave in one call — also migrate to .on()
Hands-On
Examples Gallery
Five examples cover binding, eventData, triggering, migration from .mouseenter() to .on("mouseenter"), and legacy enter/leave chaining. Use the Try-it links to run each snippet in the browser. Remember: binding with .mouseenter(handler) is deprecated — these demos show legacy syntax you will encounter in older code.
📚 Binding & Triggering
Legacy .mouseenter() signatures for binding handlers and firing events programmatically.
Example 1 — Bind Handler with .mouseenter(handler)
The canonical legacy pattern — attach a function that runs when the pointer enters the element.
jQuery
$( "#outer" ).mouseenter( function() {
$( "#log" ).append( " Handler ran via .mouseenter(function(){ ... }). " );
} );
Pointer enters #outer → log appends handler message
Moving over Inner child → handler does NOT fire again
Deprecated — prefer .on("mouseenter", fn) for new code
How It Works
.mouseenter(fn) registers the function on the element. jQuery internally routes this to .on("mouseenter", fn). The handler runs once when the pointer crosses into the outer boundary.
Example 2 — Pass eventData with .mouseenter(eventData, handler)
Since jQuery 1.4.3, pass an object before the handler — it arrives as event.data.
jQuery
$( ".preview" ).mouseenter( { panel: "tooltip" }, function( event ) {
var id = $( this ).data( "id" );
$( "#log" ).text(
"Preview: " + id + " | eventData.panel: " + event.data.panel
);
} );
Enter Photo A → "Preview: photo-a | eventData.panel: tooltip"
Enter Photo B → "Preview: photo-b | eventData.panel: tooltip"
Same handler, shared eventData on every .preview link
How It Works
jQuery stores the { panel: "tooltip" } object and injects it into event.data when any matched preview link is entered. Modern equivalent: .on("mouseenter", { panel: "tooltip" }, fn).
Example 3 — Trigger mouseenter with No-Argument .mouseenter()
Calling .mouseenter() without a handler fires the mouseenter event programmatically.
Enter #outer directly → count increments
Click #fire → $("#outer").mouseenter() → same handler runs
No-arg .mouseenter() is trigger shorthand — prefer .trigger("mouseenter")
How It Works
The first .mouseenter(function(){ ... }) binds a handler on #outer. The second binds on #fire and calls $("#outer").mouseenter() with no arguments — that synthetically fires mouseenter. Replace with $("#outer").trigger("mouseenter") for clarity.
📈 Migration & Enter/Leave Chaining
Compare legacy and modern APIs, and chain enter with leave handlers.
Example 4 — Migration: .mouseenter(fn) vs .on("mouseenter", fn)
Both bind the same mouseenter event — .on() is the recommended API for new code.
jQuery
$( "#legacy" ).mouseenter( function() {
$( "#log" ).text( "Legacy: .mouseenter(function(){ ... }) — deprecated since jQuery 3.3." );
} );
$( "#modern" ).on( "mouseenter", function() {
$( "#log" ).text( "Modern: .on('mouseenter', function(){ ... }) — use this for new code." );
} );
Enter #legacy → legacy deprecation message
Enter #modern → modern .on("mouseenter") message
Behavior is identical — only the API name differs
How It Works
Under the hood, .mouseenter(fn) calls .on("mouseenter", fn). Migration is a straight rename with no behavior change for simple bindings. The advantage of .on() is delegation — $("#menu").on("mouseenter", "li", fn) — which .mouseenter() cannot do.
Example 5 — Chained .mouseenter() and .mouseleave() for Highlight
Legacy pattern — add highlight on enter, remove on leave. Prefer explicit .on("mouseenter") / .on("mouseleave") in new code over deprecated .hover().
Enter #card → .highlight class added
Leave #card → .highlight removed
Same as .hover(fnIn, fnOut) — but explicit event names are clearer
How It Works
Chaining .mouseenter(fn) and .mouseleave(fn) gives complete hover behavior without the deprecated .hover() wrapper. Both shorthand methods are deprecated — migrate to .on("mouseenter", fn).on("mouseleave", fn).
Applications
🚀 Common Use Cases
Reading legacy code — recognize $("#menu").mouseenter(fn) as equivalent to .on("mouseenter", fn) in older dropdown plugins.
Tooltip plugins — legacy code often uses .mouseenter(fn) to show tooltips — migrate to .on("mouseenter", fn).
jQuery simulates the mouseenter event in every browser it supports. The .mouseenter() method itself is a jQuery API — it works in jQuery 1.x, 2.x, and 3.x. Binding via .mouseenter(handler) is deprecated since 3.3 but still functional; triggering via no-arg .mouseenter() also remains supported.
✓ jQuery 1.0+
jQuery .mouseenter() method
Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.3 — use .on('mouseenter') for new projects. Native equivalent for binding: element.addEventListener('mouseenter', fn).
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
.mouseenter()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('mouseenter') and triggers to .trigger('mouseenter') when updating code.
Wrap Up
Conclusion
The jQuery .mouseenter() method is the legacy shorthand for binding and triggering mouseenter handlers. Use .mouseenter(handler) or .mouseenter(eventData, handler) to bind — both deprecated since jQuery 3.3. Use no-argument .mouseenter() to trigger — equivalent to .trigger("mouseenter").
For new code, prefer .on("mouseenter", fn) for binding and .trigger("mouseenter") for programmatic firing. When you encounter .mouseenter() in older projects, recognize it, understand it, and migrate when practical. For comparison with mouseover, delegation, and pairing with mouseleave, continue with the jQuery mouseenter event tutorial.
Write new code with deprecated .mouseenter(handler)
Assume .mouseenter() supports delegation — it does not
Confuse .mouseenter(fn) (bind) with .mouseenter() (trigger)
Use mouseover when you mean enter-once behavior on nested content
Copy deprecated patterns from old tutorials without modernizing them
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .mouseenter()
Legacy bind, modern migrate.
6
Core concepts
.me01
.mouseenter(fn)
Bind
Deprecated
data02
eventData
Since 1.4.3
Handler
()03
.mouseenter()
Trigger
No args
.on04
.on("mouseenter")
Modern
Replace
⚡05
.trigger()
Fire
Programmatic
3.306
Deprecated
Since 3.3
Migrate
❓ Frequently Asked Questions
The .mouseenter() method has two roles. With a handler argument — .mouseenter(handler) or .mouseenter(eventData, handler) — it binds a function that runs when the pointer enters the matched element. With no arguments — .mouseenter() — it triggers the mouseenter event on each matched element, running bound handlers. Both forms have been part of jQuery since 1.0; the binding form is deprecated since 3.3.
Yes — the binding signatures .mouseenter(handler) and .mouseenter(eventData, handler) are deprecated since jQuery 3.3. Use .on('mouseenter', handler) or .on('mouseenter', eventData, handler) instead. The no-argument .mouseenter() trigger form still works but .trigger('mouseenter') is clearer and preferred in modern code. Existing legacy code continues to run in jQuery 3.x; migrate when you touch those files.
.mouseenter(handler) registers a callback — it does not fire the event immediately. .mouseenter() with no arguments triggers the mouseenter event programmatically on every matched element, the same as .trigger('mouseenter'). The handler form is deprecated for binding; the no-arg form is a trigger shorthand. Always check whether parentheses contain a function before reading legacy jQuery code.
Replace .mouseenter(fn) with .on('mouseenter', fn). Replace .mouseenter(data, fn) with .on('mouseenter', data, fn). Replace no-arg .mouseenter() with .trigger('mouseenter'). Replace .unbind('mouseenter') cleanup with .off('mouseenter'). Under the hood, .mouseenter(handler) already delegates to .on('mouseenter') — migration is a straight rename with no behavior change for simple bindings.
Yes. jQuery 3.x keeps .mouseenter() for backward compatibility with jQuery 1.x and 2.x codebases. It still binds and triggers correctly. The API docs mark it deprecated to steer new projects toward .on() and .trigger(). Do not use .mouseenter(handler) in new code — prefer the modern API covered in the jQuery mouseenter event tutorial.
Since jQuery 1.4.3, you can pass an object as the first argument before the handler. jQuery attaches it to event.data inside the callback — for example, .mouseenter({ panel: 'preview' }, fn) lets fn read event.data.panel. This avoids closures when the same handler serves multiple elements. The modern equivalent is .on('mouseenter', { panel: 'preview' }, fn).
Did you know?
The deprecated .hover(handlerIn, handlerOut) method never introduced a browser "hover" event — it always mapped to mouseenter and mouseleave. That means .mouseenter(handler) is literally half of what .hover() did. When migrating legacy hover code, split .hover(fnIn, fnOut) into .on("mouseenter", fnIn).on("mouseleave", fnOut) — or rename individual .mouseenter(fn) calls to .on("mouseenter", fn).