jQuery .mouseout() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Mouse Events

Definition

.mouseout() is jQuery’s legacy shorthand for the mouseout event (since 1.0). Pass a handler to bind; call it with no arguments to trigger. Binding forms are deprecated since 3.3 — prefer .on() / .trigger().

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#box").mouseout(fn)               // bind (deprecated)
$("#box").mouseout({ id: 1 }, fn)    // bind + eventData (deprecated)
$("#box").mouseout()                 // trigger (prefer .trigger)

// Modern:
$("#box").on("mouseout", fn)
$("#box").trigger("mouseout")

// Nested menus? Prefer mouseleave instead.
CallWhat it does
.mouseout()Learn jQuery .mouseout(): bind handlers, pass eventData, trigger with no args, migrate to .on('mouseout') and .trigger('mouseout'), bubbling pitfalls, examples, and FAQs. Deprecated since 3.3.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Decide if the call is a bind (function passed) or a trigger (no args).
Step 2For new work, use .on("mouseout", handler) instead of .mouseout(handler).
Step 3Replace no-arg .mouseout() with .trigger("mouseout").

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Bind with .mouseout(handler)

Log leave events with the deprecated binding shorthand — child crossings also fire.

jQuery
$("#outer").mouseout(function () {
  $("#log").append("Handler for mouseout called.\n");
});

// Prefer: $("#outer").on("mouseout", function () { … });
Try It Yourself

How It Works

  1. Pass a function. .mouseout(fn) registers the handler (deprecated).
  2. Leave the element. Exiting to the page runs the function.
  3. Cross into a child. Outer → Inner also fires because mouseout bubbles.

Example 2 — Pass eventData

Since 1.4.3, pass an object before the handler — available as event.data.

jQuery
$(".tooltip").mouseout({ action: "hide" }, function (event) {
  $("#log").text(
    "Hide: " + $(this).text() +
    " | action: " + event.data.action
  );
});

// Prefer: .on("mouseout", { action: "hide" }, fn)
Try It Yourself

How It Works

  1. First argument is data. { action: "hide" } is not the handler.
  2. Second argument is the function. It runs on each leave.
  3. Read event.data. Shared config without an extra closure.

Example 3 — Trigger with No Arguments

Call .mouseout() with no args to fire bound handlers programmatically.

jQuery
var count = 0;

$("#outer").mouseout(function () {
  count++;
  $("#log").text("Handler fired (count: " + count + ")");
});

$("#fire").on("click", function () {
  $("#outer").mouseout();  // prefer .trigger("mouseout")
});
Try It Yourself

How It Works

  1. Bind first. A handler must exist for the trigger to do anything useful.
  2. Empty call fires. .mouseout() synthesizes the event.
  3. Same handlers run. Real leaves and triggers share the callback.

Frequently Asked Questions

With a handler — .mouseout(fn) or .mouseout(eventData, fn) — it binds a function that runs when the pointer leaves the element (and when moving into a child, because mouseout bubbles). With no arguments — .mouseout() — it triggers the event. Binding forms are deprecated since jQuery 3.3.
Yes. Prefer .on('mouseout', handler) for binding and .trigger('mouseout') for firing. jQuery 3.x still runs the shorthand for compatibility; migrate when you touch legacy code.
.mouseout(fn) only registers a callback. .mouseout() with no arguments fires the event on each matched element (same idea as .trigger('mouseout')). Check whether a function is passed before reading old code.
mouseout bubbles. Leaving Outer into Inner still notifies Outer. For nested menus, prefer .on('mouseleave', fn) — mouseleave ignores child crossings.
Replace .mouseout(fn) with .on('mouseout', fn). Replace .mouseout(data, fn) with .on('mouseout', data, fn). Replace no-arg .mouseout() with .trigger('mouseout'). Unbind with .off('mouseout').
Yes for backward compatibility. It still binds and triggers correctly. Do not use it in new projects — use the modern mouseout event API, or mouseleave for nested UI.

Next: mouseover Event — Enter Detection & Bubbling

Learn the bubbling enter event that pairs with mouseout in legacy hover code.

mouseover Event — Enter Detection & Bubbling tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

9 people found this page helpful