jQuery .mouseenter() Method — Deprecated Shorthand

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

Definition

.mouseenter() is a shorthand for binding or triggering the mouseenter event (pointer enters; children do not re-fire). With a handler it binds; with no arguments it triggers. Prefer .on / .trigger in new code.

Syntax

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

jQuery
$("#box").mouseenter(fn)           // bind (deprecated)
$("#box").mouseenter(data, fn)     // bind + eventData (deprecated)
$("#box").mouseenter()             // trigger (prefer .trigger)

// Modern:
$("#box").on("mouseenter", fn)
$("#box").trigger("mouseenter")
CallWhat it does
.mouseenter()Learn the deprecated jQuery .mouseenter() shorthand: bind with .mouseenter(handler), pass eventData, trigger with no-arg .mouseenter(), and migrate to .on(\

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

Parameters

ParameterDescription
Step 1Select element(s): $("#box").
Step 2Bind (legacy): .mouseenter(function (event) { ... }).
Step 3Optional data (1.4.3+): .mouseenter({ key: "v" }, handler) → event.data.

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

Deprecated shorthand for .on("mouseenter", handler).

jQuery
$("#target").mouseenter(function () {
  console.log("Handler ran via .mouseenter(fn).");
});
Try It Yourself

How It Works

  1. Select #target.
  2. .mouseenter(fn) registers the callback (like .on("mouseenter", fn)).
  3. Pointer enters the element from outside.

Example 2 — Pass eventData

Since 1.4.3: data object before the handler → event.data.

jQuery
$(".card").mouseenter({ zone: "header" }, function (event) {
  console.log("zone:", event.data.zone);
  console.log("id:", $(this).data("id"));
});
Try It Yourself

How It Works

  1. First arg is data, second is the handler.
  2. event.data holds that object inside the callback.
  3. this is still the entered element.

Example 3 — Trigger with No Args

.mouseenter() with no arguments fires the event — prefer .trigger("mouseenter").

jQuery
$("#target").mouseenter(function () {
  console.log("Handler for mouseenter called.");
});

$("#fire").click(function () {
  $("#target").mouseenter();  // same idea as .trigger("mouseenter")
});
Try It Yourself

How It Works

  1. Bind a handler on #target.
  2. #fire listens for click.
  3. $("#target").mouseenter() runs #target’s handlers.

Frequently Asked Questions

With a handler — .mouseenter(handler) or .mouseenter(eventData, handler) — it binds a callback that runs when the pointer enters the element. With no arguments — .mouseenter() — it triggers mouseenter on each matched element. Binding forms are deprecated since jQuery 3.3.
Yes. Prefer .on("mouseenter", handler) or .on("mouseenter", eventData, handler) to bind, and .trigger("mouseenter") to fire. jQuery 3.x still runs .mouseenter() for compatibility.
.mouseenter(handler) only registers a callback. .mouseenter() with no arguments triggers the event (same idea as .trigger("mouseenter")).
Replace .mouseenter(fn) with .on("mouseenter", fn). Replace .mouseenter(data, fn) with .on("mouseenter", data, fn). Replace no-arg .mouseenter() with .trigger("mouseenter").
mouseenter does not re-fire when the pointer moves into a child. mouseover does. Prefer mouseenter for parent hover with nested content.
Since 1.4.3 you can pass data before the handler. It appears as event.data inside the callback. Modern form: .on("mouseenter", eventData, handler).

Next: mouseleave Event — Leave Without Child Bubbling

Learn the modern .on("mouseleave") / .trigger("mouseleave") API.

mouseleave Event — Leave Without Child 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.

8 people found this page helpful