jQuery mouseenter Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Mouse events

What You’ll Learn

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

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 mouseenter event (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.

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.

📝 Syntax

The modern jQuery API for the mouseenter event has two main forms — binding a handler and triggering the event:

1. Bind a handler — .on("mouseenter" [, eventData ], handler) (since 1.7)

jQuery
.on( "mouseenter" [, eventData ], handler )
  • eventData — optional object passed to the handler as event.data.
  • handler — function called each time mouseenter fires: function( event ) { ... }.

2. Event delegation — .on("mouseenter", selector, handler)

jQuery
$( "#menu" ).on( "mouseenter", "li", function( event ) {
  // runs when pointer enters any li inside #menu
} );

3. Trigger the event — .trigger("mouseenter") (since 1.0)

jQuery
.trigger( "mouseenter" )
  • Runs bound mouseenter handlers on the matched element(s).
  • Use .triggerHandler("mouseenter") to run handlers without bubbling.

4. Unbind — .off("mouseenter" [, selector] [, handler])

jQuery
$( "#outer" ).off( "mouseenter" );              // remove all mouseenter handlers
$( "#menu" ).off( "mouseenter", "li", fn );     // remove delegated handler

Official jQuery API examples

jQuery
$( "#outer" ).on( "mouseenter", function() {
  $( "#log" ).append( " Handler for `mouseenter` called. " );
} );

$( "#other" ).on( "click", function() {
  $( "#outer" ).trigger( "mouseenter" );
} );

Return value

  • .on() and .trigger() return the original jQuery object for chaining.
  • Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).

⚡ Quick Reference

GoalCode
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")

📋 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

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.

jQuery
$( "#outer" ).on( "mouseenter", function() {
  $( "#log" ).append( " Handler for `mouseenter` called. " );
} );
Try It Yourself

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.

jQuery
$( "#outer" ).on( "mouseenter", function() {
  $( "#log" ).append( " Handler for `mouseenter` called. " );
} );

$( "#other" ).on( "click", function() {
  $( "#outer" ).trigger( "mouseenter" );
} );
Try It Yourself

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" );
  } );
Try It Yourself

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.

jQuery
$( ".card" )
  .on( "mouseenter", function() {
    $( this ).addClass( "highlight" );
  } )
  .on( "mouseleave", function() {
    $( this ).removeClass( "highlight" );
  } );
Try It Yourself

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.

jQuery
$( "#menu" ).on( "mouseenter", "li", function() {
  $( this ).addClass( "active" );
} ).on( "mouseleave", "li", function() {
  $( this ).removeClass( "active" );
} );
Try It Yourself

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.

🚀 Common Use Cases

  • Dropdown menus$("#nav-item").on("mouseenter", showSubmenu).on("mouseleave", hideSubmenu).
  • 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.

📝 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.

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 Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
mouseenter Universal

Bottom line: Safe in any jQuery project. Prefer .on('mouseenter') over deprecated .mouseenter() for binding. Pair with mouseleave for stable hover menus.

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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Six things to remember about the mouseenter event

Enter, leave, no bubble.

6
Core concepts
02

.trigger()

Fire

Programmatic
over 03

vs mouseover

No bubble

Compare
leave 04

mouseleave

Pair

Exit
li 05

Delegate

Dynamic

Pattern
.off 06

.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.

Next: .mouseenter() Method

Learn the deprecated shorthand — and how to migrate to .on("mouseenter").

.mouseenter() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful