jQuery mouseleave Event — Leave Without Child Bubbling

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

What Is the mouseleave Event?

mouseleave fires when the pointer leaves the element it is bound to. Leaving a child does not fire it (unlike mouseout). Bind with .on("mouseleave", handler) (jQuery 1.7+).

Remember
$("#outer").on("mouseleave", function () { ... })
$("#outer").trigger("mouseleave")

// Leave element → fires once
// Leave a child but stay inside element → does NOT fire
// Prefer on/trigger — not the deprecated .mouseleave()
NeedUse
Bind handler.on("mouseleave", handler)
Fire event.trigger("mouseleave")
Enter the elementmouseenter
Also fire on childrenmouseout

How to Use mouseleave

Select the container, bind leave (and usually enter), avoid mouseout when children would spam handlers.

  1. Select the element(s): $("#outer"), $(".card"), etc.
  2. Bind: .on("mouseleave", function (event) { ... }).
  3. Pair with .on("mouseenter", …) for hover-style UI.
  4. To fire in code: .trigger("mouseleave"). Unbind with .off("mouseleave").
PieceRequired?Role
"mouseleave"YesEvent type string for .on / .trigger
handlerYes (bind)Runs when the pointer leaves the element
eventDataOptionalExtra data passed into the handler
Return value—jQuery set (chainable)

Pseudocode

Pseudocode
function onMouseleave(element, handler):
    when pointer moves from inside element → outside element:
        handler(event)
    // leaving a child but staying inside element does NOT call handler

trigger(element, "mouseleave"):
    run all mouseleave handlers on element

Cheat Sheet

Keep these facts handy when choosing leave vs out.

TopicDetail
Bind.on("mouseleave", handler) (1.7+)
Trigger.trigger("mouseleave") (1.0+)
WhenPointer leaves the bound element
vs mouseoutDoes not re-fire on children
Pairmouseenter / .hover()
Unbind.off("mouseleave")
Deprecated.mouseleave() shorthand (3.3+)

Live Preview

Run presets that use .on("mouseleave") and .trigger("mouseleave").

Uses .on("mouseleave") and .trigger("mouseleave") — same ideas as the examples below.

Result
Handler for mouseleave called.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Bind a mouseleave Handler

Official style: .on("mouseleave", …) on a container.

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

How It Works

  1. Select #outer.
  2. Bind with .on("mouseleave", handler).
  3. Pointer leaves the element entirely.
  4. Handler runs once for that leave — not when leaving children only.

Example 2 — Trigger mouseleave from Code

Fire the same handlers with a click on another control.

jQuery
$("#outer").on("mouseleave", function () {
  console.log("Handler for mouseleave called.");
});

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

How It Works

  1. Bind the real handler on #outer.
  2. Another control listens for click.
  3. trigger("mouseleave") runs #outer’s handlers.
  4. Same message as moving the pointer out of #outer.

Example 3 — mouseleave vs mouseout

Leaving a child re-fires mouseout, not mouseleave.

jQuery
var leaveCount = 0;
var outCount = 0;

$("#leaveBox").on("mouseleave", function () {
  leaveCount += 1;
  console.log("mouseleave:", leaveCount);
});

$("#outBox").on("mouseout", function () {
  outCount += 1;
  console.log("mouseout:", outCount);
});
// Leave each box entirely, and also leave Inner while staying in the box:
// mouseleave stays 1 for full leave; mouseout increases on Inner too.
Try It Yourself

How It Works

  1. mouseleave counts only leaving the bound box.
  2. mouseout also fires when you leave the Inner child.
  3. Choose mouseleave for stable hover cleanup on parents with children.
  4. Official tip. Child moves usually make mouseout undesirable.

Example 4 — Pair With mouseenter

Enter and leave without child noise — classic hover pair.

jQuery
$("#card")
  .on("mouseenter", function () {
    console.log("mouse enter");
  })
  .on("mouseleave", function () {
    console.log("mouse leave");
  });
Try It Yourself

How It Works

  1. mouseenter runs when the pointer enters #card.
  2. mouseleave runs when it leaves #card.
  3. Children inside #card do not toggle these twice.
  4. Shortcut. .hover(enter, leave) wires both.

Edge Cases & Pitfalls

Most bugs come from using mouseout when you meant mouseleave.

children

Do not use mouseout for parent hover

Nested elements re-fire mouseout. Prefer mouseenter / mouseleave for cards and menus.

deprecated

Avoid .mouseleave() in new code

Use .on("mouseleave") / .trigger("mouseleave"). The method shorthand is deprecated since 3.3.

touch

No true hover on touch

Pointer enter/leave is mouse-oriented. Provide click/tap paths for touch UIs.

simulate

jQuery normalizes the event

Originally IE-only; jQuery simulates mouseleave so it works in all supported browsers.

Browser Support

.on("mouseleave") has shipped since jQuery 1.7 (.trigger("mouseleave") since 1.0). jQuery simulates mouseleave so it works in all modern browsers with jQuery loaded.

✓ jQuery 1.7+

mouseleave event

Pointer leaves the bound element — without re-firing on child elements.

100% Browser support
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
mouseleave Excellent

Bottom line: Bind with .on("mouseleave"). Prefer it over mouseout when the element has children.

Performance Notes

ApproachCostBest for
mouseleaveFewer callsParent hover cleanup with children
mouseoutMore callsWhen you truly need child leaves
Heavy work in handlerJanky hoverKeep enter/leave light

Prefer mouseenter / mouseleave for UI hover — fewer accidental re-entries means less work and cleaner state.

Key Takeaways

  • Role: pointer leaves the bound element.
  • vs out: children do not re-fire mouseleave.
  • API: use .on / .trigger, not the shorthand.
  • Pair: mouseenter or .hover().

One line: .on("mouseleave") for leave-once hover cleanup — use it when the element has children.

Frequently Asked Questions

mouseleave fires when the pointer leaves the bound element. Unlike mouseout, moving out of a child into another part of the same parent does not fire it. Bind with .on("mouseleave", handler) (jQuery 1.7+). jQuery simulates the event across browsers.
Prefer .on("mouseleave", handler). The .mouseleave(handler) shorthand is deprecated since jQuery 3.3. To fire the event, use .trigger("mouseleave") instead of .mouseleave().
mouseout bubbles and also fires when the pointer leaves a child for another descendant or the parent. mouseleave does not — it fires only when leaving the element it is bound to, not when leaving a descendant.
Use mouseenter for when the pointer enters the element (same non-child-bubbling behavior). .hover(enterFn, leaveFn) is a convenience that wires both.
Call $(selector).trigger("mouseleave"). That runs bound handlers without needing a real pointer move.
No — that is the point versus mouseout. Leaving a child does not trigger a mouseleave handler bound only on the parent.

Next: .mouseleave() shorthand

See the deprecated method form — then keep using .on / .trigger.

.mouseleave() 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.

8 people found this page helpful