The mouseenter event fires when the mouse pointer enters an element. This tutorial covers binding with .on("mouseenter"), triggering with .trigger("mouseenter"), comparing mouseenter with mouseover, pairing with mouseleave, and building stable hover menus without flicker.
01
.on()
Bind handler
02
.trigger()
Fire enter
03
vs over
No bubble
04
mouseleave
Pair exit
05
Menus
Stable hover
06
Since 1.7
Modern API
Fundamentals
Introduction
Hover effects are everywhere — dropdown menus, image previews, and highlighted table rows all react when the pointer enters an element. jQuery’s mouseenter event is the reliable way to run JavaScript when that happens, especially on elements that contain nested children.
The official jQuery API distinguishes the mouseenterevent (bound with .on("mouseenter") since 1.7) from the deprecated .mouseenter()method used in older code. jQuery simulates mouseenter in every browser — the event was originally proprietary to Internet Explorer. To programmatically fire a handler, use .trigger("mouseenter") — available since jQuery 1.0.
Concept
Understanding the mouseenter Event
The mouseenter event is sent to an element when the mouse pointer enters that element. Unlike mouseover, it does not re-fire when the pointer moves over child elements inside the bound element — the handler runs once when entering the outer boundary and stays quiet while moving among children.
This non-bubbling behavior is why hover menus and tooltips prefer mouseenter paired with mouseleave. With mouseover, moving from a parent into a child looks like leaving and re-entering — causing flicker, duplicate AJAX calls, and menus that collapse unexpectedly.
💡
Beginner Tip
Think of mouseenter as “the pointer crossed into this box” and mouseleave as “the pointer left this box entirely.” Moving between children inside the box does not count as leave or re-enter. For simple color changes only, CSS :hover may be enough — use jQuery when you need behavior.
Foundation
📝 Syntax
The modern jQuery API for the mouseenter event has two main forms — binding a handler and triggering the event:
.on() and .trigger() 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
Code
Bind mouseenter handler
$("#box").on("mouseenter", fn)
Pair enter and leave
.on("mouseenter", in).on("mouseleave", out)
Pass data to handler
$("#box").on("mouseenter", { id: 1 }, fn)
Delegated mouseenter on children
$("#menu").on("mouseenter", "li", fn)
Trigger mouseenter programmatically
$("#outer").trigger("mouseenter")
Highlight on enter, reset on leave
.on("mouseenter", add).on("mouseleave", remove)
Remove mouseenter handlers
$("#box").off("mouseenter")
Compare
📋 mouseenter vs mouseover vs mouseleave vs CSS :hover
Four ways to respond when the pointer moves over elements — choose the event that matches your hover needs.
mouseenter
enter once
Fires when pointer enters bound element — ignores child crossings; ideal for menus
mouseover
bubbles
Re-fires on every child boundary crossing — can cause flicker on nested content
mouseleave
exit once
Fires when pointer leaves bound element entirely — pair with mouseenter
CSS :hover
style only
Stylesheet pseudo-class — no JavaScript; use for simple color or visibility changes
Hands-On
Examples Gallery
Examples 1–3 follow the official jQuery API documentation. Examples 4–5 cover highlight toggling and event delegation. Use the Try-it links to run each snippet in the browser.
📚 Binding & Triggering
Official jQuery demos for mouseenter handlers and programmatic triggers.
Example 1 — Official Demo: Bind Handler on #outer
Append a log message when the pointer enters the outer element — the canonical .on("mouseenter") pattern.
Pointer enters #outer → #log appends: "Handler for mouseenter called."
Moving over Inner child inside #outer → handler does NOT fire again
mouseenter fires once per entry into the bound element
How It Works
.on("mouseenter", fn) registers the function on #outer. jQuery calls it when the pointer crosses into the outer boundary. Moving among children inside does not re-trigger — that is the key difference from mouseover.
Example 2 — Official Demo: #other Triggers mouseenter on #outer
One element programmatically fires the mouseenter handler on another.
Move into #outer → log message appended
Click #other → $("#outer").trigger("mouseenter") → same log message
Programmatic trigger invokes bound handlers
How It Works
.trigger("mouseenter") synthetically fires the mouseenter event on #outer, running the same handler as a physical pointer entry. Useful for testing hover behavior or keyboard-accessible fallbacks.
Example 3 — Official Demo: mouseover vs mouseenter
Side-by-side comparison — mouseover re-fires when entering the inner child; mouseenter does not.
jQuery
var i = 0;
$( "div.overout" )
.on( "mouseover", function() {
$( "p", this ).first().text( "mouse over" );
$( "p", this ).last().text( ++i );
} )
.on( "mouseout", function() {
$( "p", this ).first().text( "mouse out" );
} );
var n = 0;
$( "div.enterleave" )
.on( "mouseenter", function() {
$( "p", this ).first().text( "mouse enter" );
$( "p", this ).last().text( ++n );
} )
.on( "mouseleave", function() {
$( "p", this ).first().text( "mouse leave" );
} );
Left box (mouseover): counter increments when entering outer AND inner child
Right box (mouseenter): counter increments only when entering outer boundary
Move between outer and inner on left → count jumps; on right → stable
How It Works
The official API demo uses nested divs with an inner yellow child. mouseover bubbles — crossing into the inner div counts as a new over event. mouseenter ignores child crossings — the counter increments only once per entry into the outer box.
📈 Highlight & Delegation
Practical patterns for cards, menus, and dynamic lists.
Example 4 — Highlight Card on Enter, Reset on Leave
Add a highlight class on mouseenter and remove it on mouseleave — the standard hover pair.
Enter a .card → .highlight class added
Leave the card → .highlight removed
Each card toggles independently — $(this) is the hovered card
How It Works
Binding both events on the same collection gives each card independent enter/leave behavior. This replaces the deprecated .hover(fnIn, fnOut) pattern with explicit, readable event names.
Example 5 — Delegated mouseenter on Dynamic Menu Items
Bind once on the parent #menu — pointer enter on current and future li elements is handled.
Enter existing li → toggles .active class
Append new li via JavaScript → enter/leave still works
One handler pair on #menu covers all li children
How It Works
jQuery listens for mouseenter on #menu and checks whether the event target matches li. If so, it runs the handler with this set to that list item. New items added with .append() need no extra binding — the parent handler covers them.
Image previews — load or reveal a preview panel when the pointer enters a thumbnail link.
Table row highlight — $("tr").on("mouseenter", fn).on("mouseleave", fn) for hover rows in data tables.
Tooltip show — display a tooltip on enter, hide on leave — stable even with nested icon spans inside the trigger.
Lazy AJAX — fetch detail data once when the pointer enters a card, not on every child crossing.
Keyboard fallbacks — $("#btn").on("focus", function(){ ... }).trigger("mouseenter") for accessibility parity.
🧠 How mouseenter Differs from mouseover
1
Pointer enters outer box
User moves cursor into the bound element — both mouseover and mouseenter fire.
enter
2
Pointer moves to child
mouseover fires again on the child crossing. mouseenter stays silent — still inside the outer boundary.
child cross
3
Pointer leaves entirely
mouseout and mouseleave fire when the pointer exits the outer element — not when moving between children.
leave
4
👉
Stable hover
Use mouseenter + mouseleave for menus and nested content — one enter, one leave, no flicker.
Important
📝 Notes
Bind with .on("mouseenter", handler) since jQuery 1.7 — not the deprecated .mouseenter(handler) method.
Trigger with .trigger("mouseenter") since jQuery 1.0.
jQuery simulates mouseenter in all browsers — it was originally an IE proprietary event.
mouseenter does not re-fire when moving over child elements — unlike mouseover.
Always pair with mouseleave for complete hover behavior — not mouseout, which has the same bubbling issue as mouseover.
Any HTML element can receive mouseenter — not limited to links or buttons.
Use .off("mouseenter") to remove handlers — avoid deprecated .unbind("mouseenter").
Touch devices have no true hover — provide click/tap fallbacks for critical UI.
Compatibility
Browser Support
jQuery simulates the mouseenter event in every browser it supports — the native event was originally IE-specific but is now widely available. jQuery’s .on("mouseenter") (since 1.7) and .trigger("mouseenter") (since 1.0) provide consistent cross-browser behavior.
✓ jQuery 1.7+
jQuery mouseenter event
Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers. Native equivalent: element.addEventListener('mouseenter', fn) — widely supported in current browsers; jQuery ensured parity in older IE. Adds collection binding, eventData, delegation, and .trigger().
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
mouseenterUniversal
Bottom line: Safe in any jQuery project. Prefer .on('mouseenter') over deprecated .mouseenter() for binding. Pair with mouseleave for stable hover menus.
Wrap Up
Conclusion
The jQuery mouseenter event fires when the pointer enters an element — once per entry, without re-firing on child crossings. Bind handlers with .on("mouseenter", fn), pair with .on("mouseleave", fn), and fire handlers programmatically with .trigger("mouseenter").
Choose mouseenter over mouseover when nested content would cause flicker. Use CSS :hover for simple styling. Replace deprecated .hover(fnIn, fnOut) with explicit enter and leave bindings. For touch devices, remember hover has no mobile equivalent — add click fallbacks where needed.
Bind with .on("mouseenter", handler) — the modern, delegation-capable API
Pair mouseenter with mouseleave — not mouseover / mouseout
Use CSS :hover when only colors or visibility change
Use event delegation for dynamic menus: .on("mouseenter", "li", fn)
Call .off("mouseenter mouseleave") when removing hover behavior
❌ Don’t
Use deprecated .mouseenter(handler) for new code — use .on("mouseenter")
Swap mouseenter for mouseover on containers with nested children
Rely on hover alone for critical mobile UI — add tap/click fallbacks
Forget to unbind enter/leave handlers when tearing down SPAs
Assume .hover() uses a "hover" event — it maps to enter/leave
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about the mouseenter event
Enter, leave, no bubble.
6
Core concepts
.on01
.on("mouseenter")
Bind
API
⚡02
.trigger()
Fire
Programmatic
over03
vs mouseover
No bubble
Compare
leave04
mouseleave
Pair
Exit
li05
Delegate
Dynamic
Pattern
.off06
.off("mouseenter")
Unbind
Cleanup
❓ Frequently Asked Questions
The mouseenter event fires when the mouse pointer enters an element. In modern jQuery, bind handlers with .on('mouseenter', handler) since version 1.7. jQuery simulates this event across all browsers — it was originally proprietary to Internet Explorer. Any HTML element can receive mouseenter.
mouseenter fires only when the pointer enters the element it is bound to — not when moving over child elements inside it. mouseover bubbles and re-fires every time the pointer crosses a child boundary. For hover menus, tooltips, and highlight effects on containers with nested content, mouseenter (paired with mouseleave) avoids flickering and duplicate handler calls.
Use CSS :hover when only colors, visibility, or simple styling change — no JavaScript required. Use jQuery mouseenter when you need DOM changes, animations, AJAX previews, or logic CSS cannot express. For pure styling, prefer CSS; for behavior, use .on('mouseenter') and .on('mouseleave') in modern code.
Call .trigger('mouseenter') on the target element: $('#outer').trigger('mouseenter'). Available since jQuery 1.0, trigger runs bound mouseenter handlers. To run handlers without bubbling, use .triggerHandler('mouseenter') instead.
mouseenter fires when the pointer enters an element. mouseleave fires when the pointer leaves that same element — including when moving directly to a child, mouseenter on the parent does not re-fire, and mouseleave on the parent does not fire until the pointer exits the entire element. Pair them for stable hover behavior.
The deprecated .hover(handlerIn, handlerOut) method binds mouseenter and mouseleave in one call. Under the hood, .hover() maps to those events — not a separate 'hover' event. For new code, use .on('mouseenter', fnIn).on('mouseleave', fnOut) instead of .hover(). See the jQuery .hover() tutorial for migration details.
Did you know?
The mouseenter event was originally proprietary to Internet Explorer. Because of its usefulness — especially the non-bubbling behavior that avoids hover flicker on nested elements — jQuery simulates it in every browser. That is why you can rely on .on("mouseenter") in cross-browser projects even in older jQuery versions that predated native mouseenter support in all browsers.