jQuery .mouseover() Method

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

Definition

.mouseover() is jQuery’s legacy shorthand for the mouseover 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").mouseover(fn)              // bind (deprecated)
$("#box").mouseover({ id: 1 }, fn)   // bind + eventData (deprecated)
$("#box").mouseover()                // trigger (prefer .trigger)

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

// Nested menus? Prefer mouseenter instead.
CallWhat it does
.mouseover()Learn jQuery .mouseover(): bind handlers, pass eventData, trigger with no args, migrate to .on('mouseover') and .trigger('mouseover'), 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("mouseover", handler) instead of .mouseover(handler).
Step 3Replace no-arg .mouseover() with .trigger("mouseover").

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 .mouseover(handler)

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

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

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

How It Works

  1. Pass a function. .mouseover(fn) registers the handler (deprecated).
  2. Enter the element. Arriving from outside runs the function.
  3. Cross into a child. Outer → Inner also fires because mouseover bubbles.

Example 2 — Pass eventData

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

jQuery
$(".tooltip").mouseover({ action: "show" }, function (event) {
  $("#log").text(
    "Show: " + $(this).text() +
    " | action: " + event.data.action
  );
});

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

How It Works

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

Example 3 — Trigger with No Arguments

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

jQuery
var count = 0;

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

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

How It Works

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

Frequently Asked Questions

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

Next: Keyboard Events

Continue into jQuery CSS helpers — add classes without touching inline styles.

Keyboard Events 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