jQuery mouseover Event

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

What Is mouseover?

The mouseover event fires when the pointer enters an element (bound with .on("mouseover") since jQuery 1.7). It bubbles — entering a child also notifies the parent. Pair historically with mouseout; for nested UI prefer mouseenter / mouseleave.

Remember
$("#outer").on("mouseover", function (event) { … })

bubbles: parent → fires when entering OR crossing into a child
mouseenter: fires only when entering from outside

event.relatedTarget → element the pointer came from
.trigger("mouseover") → run handlers manually
NeedUse
Bind enter handler$el.on("mouseover", fn)
Nested menus / tooltips.on("mouseenter", fn)
Filter child crossingsevent.relatedTarget
Fire manually$el.trigger("mouseover")

How to Use mouseover

Bind an enter handler, account for bubbling, and prefer mouseenter when nesting matters.

  1. Select the element that should react when the pointer enters.
  2. Bind with .on("mouseover", handler).
  3. If children exist, check event.relatedTarget — or switch to mouseenter.
  4. Unbind with .off("mouseover") when the feature is done.
PieceRequired?Role
ElementYesReceives enter (and child-crossing) events
handlerYesfunction(event) { … }
eventDataOptionalObject passed as event.data
Return—jQuery object (chainable)

Pseudocode

Pseudocode
on mouseover of #outer:
  from = event.relatedTarget   // where the pointer came from

  // Bubbling case: Outer → Inner still fires mouseover on Outer
  if from is still inside #outer:
    optionally ignore  // or use mouseenter instead
  else:
    run enter logic (show menu, add class, …)

Cheat Sheet

Keep these facts handy when handling pointer enter.

TopicDetail
Bind.on("mouseover", handler) (1.7+)
Trigger.trigger("mouseover") (1.0+)
Bubbles?Yes — child crossings notify the parent
vs mouseentermouseenter ignores child crossings
relatedTargetElement the pointer came from
Legacy pairmouseover + mouseout
Shorthand.mouseover() deprecated — use .on()

Live Preview

Move between Outer and Inner. Watch how often mouseover fires compared with mouseenter.

Outer

Official idea: mouseover re-fires on child crossings; mouseenter does not.

Result
mouseover count: 0
mouseenter count: 0

Move in/out of Outer and Inner

jQuery Examples

Short, copy-ready snippets. Open each Try It Yourself lab for a live editor.

Example 1 — Bind Handler on #outer

Official pattern: log when the pointer enters the outer element — including into a child.

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

How It Works

  1. Bind the event. .on("mouseover", fn) registers the handler on #outer.
  2. Enter the element. Arriving from outside runs the function.
  3. Cross into a child. Moving Outer → Inner also fires because of bubbling.
  4. Expect many calls. Nested content produces more enter events than mouseenter.

Example 2 — Trigger from Another Element

Click a button to fire the same handler with .trigger("mouseover").

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

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

How It Works

  1. Same handler. Real enters and triggers both call the bound function.
  2. Synthetic event. .trigger("mouseover") runs handlers without a real pointer move.
  3. Bubbling still applies. Use .triggerHandler("mouseover") to avoid bubble side effects.
  4. Useful for tests. Simulate enter logic without moving the mouse.

Example 3 — mouseover vs mouseenter

Official comparison: count enter events on nested boxes — adapted from the jQuery API demo.

jQuery
var i = 0;
$(".overout").on("mouseover", function () {
  $("span", this).text("mouse over x " + (++i));
});

var n = 0;
$(".enterleave").on("mouseenter", function () {
  $("span", this).text("mouse enter x " + (++n));
});
Try It Yourself

How It Works

  1. Left box uses mouseover. Every child boundary can increment the counter.
  2. Right box uses mouseenter. Only a true entry from outside increments.
  3. Same nesting. The HTML shape is identical — only the event differs.
  4. Rule of thumb. Nested UI → prefer mouseenter.

Example 4 — Filter with event.relatedTarget

Ignore false enters when the pointer came from a child still inside #outer.

jQuery
$("#outer").on("mouseover", function (event) {
  if (event.relatedTarget && $(event.relatedTarget).closest("#outer").length) {
    return; // still inside #outer
  }
  $("#log").append("Entered #outer from outside.\n");
});
Try It Yourself

How It Works

  1. Read origin. relatedTarget is where the pointer came from.
  2. Check ancestry. .closest("#outer") asks if that node is still inside.
  3. Early return. Child crossings are ignored.
  4. True entry. Only arriving from outside the container updates the log.

Example 5 — mouseover + mouseout on Flat Cards

Legacy hover pair works well on flat elements without nested interactive children.

jQuery
$(".card")
  .on("mouseover", function () {
    $("#log").text("mouseover → entered " + $(this).text());
  })
  .on("mouseout", function () {
    $("#log").text("mouseout → left " + $(this).text());
  });

// Nested content? Prefer mouseenter / mouseleave instead.
Try It Yourself

How It Works

  1. Enter with mouseover. Logs when the pointer arrives.
  2. Leave with mouseout. Logs when the pointer exits.
  3. Flat targets. No nested buttons/links → fewer false enters.
  4. Better default. For nested UI, switch to mouseenter / mouseleave.

Edge Cases & Pitfalls

Check these before opening menus or tooltips with mouseover.

bubble

Child crossings look like new entries

Outer → Inner fires mouseover on Outer. Hover styles can flicker.

prefer

Use mouseenter for nested UI

Official guidance: see mouseenter for a stable alternative to bubbling enter events.

null

relatedTarget can be null

First entry or some synthetic triggers leave it empty — guard before calling methods on it.

css

Prefer CSS :hover for style-only

If you only change colors or visibility, CSS avoids JS enter bugs entirely.

deprecated

.mouseover() shorthand

Deprecated since 3.3 — bind with .on("mouseover") instead.

Browser Support

The mouseover event is a standard DOM mouse event. jQuery’s .on("mouseover") (since 1.7) works in any browser where your jQuery build runs.

✓ jQuery 1.7+ · Browsers

jQuery mouseover event

Supported wherever jQuery runs — Chrome, Firefox, Safari, Edge, and legacy environments with a matching jQuery build.

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
mouseover Browsers

Bottom line: Safe in all common browsers with jQuery loaded. Prefer .on() / .off() over the deprecated .mouseover() shorthand.

Performance Notes

ApproachCostBest for
mouseover on nested treesMore handler callsLegacy / flat targets only
mouseenterFewer enter callsMenus, tooltips, cards with children
relatedTarget filterSmall closest() checkKeeping mouseover without flicker

Bubbling enter events are not “slow” by themselves — but extra handler runs (class toggles, DOM writes) add up. Prefer mouseenter when nesting is deep.

Key Takeaways

  • Role: run logic when the pointer enters an element.
  • Bubbles: child crossings notify the parent — unlike mouseenter.
  • Filter: use event.relatedTarget or switch to mouseenter.
  • API: prefer .on("mouseover"), not the deprecated .mouseover() shorthand.

One line: mouseover enters and bubbles — reach for mouseenter when nesting matters.

Frequently Asked Questions

mouseover fires when the pointer enters an element. Bind with .on('mouseover', handler) (since jQuery 1.7). Unlike mouseenter, it bubbles — it also fires when moving from a parent into a child inside the bound element.
When the pointer enters a child, mouseover bubbles to ancestors. A handler on an outer menu can fire again even though the user is already inside. Prefer mouseenter for nested menus, or filter with event.relatedTarget.
relatedTarget is the element the pointer came from. If it is still inside the bound element, you can ignore the event: if ($(event.relatedTarget).closest('#outer').length) return;
mouseover bubbles and re-fires on child boundary crossings. mouseenter fires only when the pointer enters the bound element from outside. For hover menus and tooltips with nested content, prefer mouseenter with mouseleave.
Call .trigger('mouseover') on the element. Use .triggerHandler('mouseover') to run handlers without bubbling.
Use .on('mouseover', handler). The .mouseover() shorthand is deprecated since jQuery 3.3. Unbind with .off('mouseover').

Next: .mouseover()

See the deprecated shorthand and how it maps to .on("mouseover").

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

10 people found this page helpful