JavaScript Element mouseover Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
DOM event
Instance event

What You’ll Learn

The mouseover event fires when a pointing device moves the cursor onto an element or one of its children. Learn addEventListener vs onmouseover, bubbling vs mouseenter, the mouseout pair, relatedTarget, and five try-it labs.

01

Kind

Instance event

02

Type

MouseEvent

03

When

Enters element / child

04

Handler

onmouseover

05

Bubbles?

Yes

06

Status

Baseline widely available

Introduction

mouseover answers: “Did the pointer move onto this element—or onto a child inside it?” Because children have their own boundaries, moving among descendants fires more mouseover events.

That is why MDN often prefers mouseenter for whole-component hover enter: mouseenter ignores descendant boundaries. mouseover is still useful when you want bubbling or per-child enter highlights.

💡
Beginner tip

Pair mouseover with mouseout (bubbling). Pair mouseenter with mouseleave (non-bubbling). Pick the pair that matches your hover model.

Understanding mouseover

An instance event that answers: “Did the pointer move onto this target (including a child)?”

  • Fires when the cursor moves onto the element or one of its children.
  • Bubbles — can be listened for on a parent (delegation).
  • Descendants — moving among child boundaries fires more events.
  • Pairmouseout when the pointer leaves.
  • Baseline Widely available on MDN (since July 2015).

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("mouseover", (event) => { });

onmouseover = (event) => { };

Event type

A MouseEvent (inherits from UIEvent and Event).

Handy properties

PropertyMeaning
targetThe element entered (often a child when using delegation)
relatedTargetWhere the pointer came from (secondary target), if any
clientX / clientYPointer position in the viewport
currentTargetThe element whose listener is running (useful with bubbling)

⚖️ mouseover vs mouseenter

Featuremouseovermouseenter
Bubbles?YesNo
Entering a childFires again (child is a new target)Does not fire again on the parent
Moving among descendantsMany eventsQuiet until full exit then re-enter
Best forDelegation / per-child enterWhole-component hover enter
Leave twinmouseoutmouseleave
💡
MDN guidance

If you only care about entering/leaving a whole component, mouseenter / mouseleave are usually more sensible.

⚡ Quick Reference

GoalCode / note
Listenel.addEventListener("mouseover", fn)
Handler propertyel.onmouseover = fn
Leave pairmouseout
Non-bubbling entermouseenter
Where did it come from?event.relatedTarget
MDN statusBaseline Widely available

🔍 At a Glance

Four facts to remember about mouseover.

Event type
MouseEvent

UIEvent + Event

Means
entered target

Or a child

Bubbles
true

Unlike mouseenter

Baseline
yes

Widely available

Examples Gallery

Examples follow MDN Element: mouseover event. Move the pointer among list items and in/out of containers.

📚 Getting Started

MDN mouseover vs mouseenter demo and the handler property.

Example 1 — List Items vs Whole List (MDN)

mouseover colors the item you enter; mouseenter colors the whole ul.

JavaScript
const test = document.getElementById("test");

test.addEventListener("mouseenter", (event) => {
  event.target.style.color = "purple";
  setTimeout(() => {
    event.target.style.color = "";
  }, 500);
});

test.addEventListener("mouseover", (event) => {
  event.target.style.color = "orange";
  setTimeout(() => {
    event.target.style.color = "";
  }, 500);
});
Try It Yourself

How It Works

List items are separate targets, so mouseover fires as you move among them; mouseenter on the ul fires once for the whole list.

Example 2 — onmouseover Property

Log when the pointer enters the stage via the handler property.

JavaScript
const stage = document.getElementById("stage");
const out = document.getElementById("out");

stage.onmouseover = (event) => {
  out.textContent = "mouseover on " + event.target.tagName.toLowerCase();
};
Try It Yourself

How It Works

Prefer addEventListener when you need multiple listeners or easy removal.

📈 Counts, Source & Delegation

Compare fire rates, read relatedTarget, and listen once on a parent.

Example 3 — Count mouseover vs mouseenter

Move among children, then leave and re-enter the parent.

JavaScript
const parent = document.getElementById("parent");
const out = document.getElementById("out");
let overCount = 0;
let enterCount = 0;

parent.addEventListener("mouseover", () => {
  overCount++;
  render();
});

parent.addEventListener("mouseenter", () => {
  enterCount++;
  render();
});

function render() {
  out.textContent = "mouseover=" + overCount + " mouseenter=" + enterCount;
}
Try It Yourself

How It Works

mouseover fires while roaming children; mouseenter waits for a full exit then re-entry.

Example 5 — Delegated mouseover Logging

One listener on the parent logs which child was entered (bubbling).

JavaScript
const list = document.getElementById("list");
const out = document.getElementById("out");

list.addEventListener("mouseover", (event) => {
  if (event.target.tagName !== "LI") return;
  out.textContent = "over " + event.target.textContent;
});
Try It Yourself

How It Works

Because mouseover bubbles, one parent listener can observe enters into many children.

🚀 Common Use Cases

  • Highlight each list item as the pointer moves over it (MDN-style).
  • Event delegation for dynamic child lists.
  • Debug hover paths with relatedTarget logs.
  • Legacy code that already uses onmouseover.
  • Teaching bubbling vs non-bubbling hover enter models.

🔧 How It Works

1

Pointer outside

Hotspot is not yet over the element or its painted children.

Outside
2

Cross into target

Move onto the element, or onto a child inside it.

Edge
3

mouseover

Fires on the entered target and bubbles upward.

Event
4

Handlers react

Style children, delegate from parents, or prefer mouseenter instead.

📝 Notes

  • MDN: Baseline Widely available (since July 2015) — no Deprecated / Experimental / Non-standard banner.
  • Bubbles; entering a child fires another mouseover (new target).
  • For whole-component enter, prefer mouseenter.
  • Pair with mouseout for the bubbling leave twin.
  • Related learning: mouseout, mouseenter, mouseleave, addEventListener(), JavaScript hub.

Browser Support

mouseover is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. Bubbling enter/over behavior is consistent across modern engines.

Baseline · Widely available

Element mouseover

Fires when the pointer enters an element or a child; bubbles unlike mouseenter.

Full Widely available
Google Chrome Full support
Yes
Mozilla Firefox Full support
Yes
Apple Safari Full support
Yes
Microsoft Edge Full support
Yes
Opera Full support
Yes
Internet Explorer Supported
Yes
mouseover Baseline

Bottom line: Useful for delegation and per-child enters. Prefer mouseenter for quiet whole-component hover enter.

Conclusion

mouseover is the bubbling “entered this target” signal—including when the pointer moves onto a child. Use it for delegation and per-child enters; prefer mouseenter for whole-component hover setup.

Continue with mouseup, mouseout, mouseenter, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use mouseover when you need bubbling / delegation
  • Check event.target carefully in parent listeners
  • Prefer mouseenter for whole-card hover enter
  • Pair with mouseout when you need the bubbling leave twin
  • Prefer addEventListener in production code

❌ Don’t

  • Expect quiet behavior while moving among children
  • Assume mouseover equals mouseenter
  • Forget that entering a child fires another mouseover
  • Build flicker-prone hover UI without filtering targets
  • Overwrite onmouseover if you need multiple listeners

Key Takeaways

Knowledge Unlocked

Five things to remember about mouseover

Entered the target—bubbling, child-aware enter.

5
Core concepts
📄02

Bubbles

unlike mouseenter

API
👆03

Child edges

more events

Why
🔄04

mouseout

leave twin

Pair
🎯05

Baseline

widely available

Status

❓ Frequently Asked Questions

It fires when a pointing device moves the cursor onto an element or one of its child elements.
No. MDN marks Element mouseover as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A MouseEvent (inherits from UIEvent and Event). Useful fields include relatedTarget, clientX, clientY, and target.
mouseover bubbles and also fires when moving onto child elements (or among child boundaries). mouseenter does not bubble and fires only when entering the element and its descendant tree as a whole.
For whole-component hover enter without descendant noise, MDN notes mouseenter/mouseleave are usually more sensible than mouseover/mouseout.
When you want bubbling/delegation, or when you care about entering individual children (for example highlighting each list item as the pointer moves over it).
Did you know?

MDN’s classic demo puts both listeners on one ul: mouseover paints individual li items orange, while mouseenter paints the whole list purple—proof that children are separate targets for mouseover.

Next: mouseup

Learn the MouseEvent that fires when a pointing-device button is released.

mouseup →

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.

5 people found this page helpful