C. Ross
C. Ross

Reputation: 31868

Difference between onMouseOver and onMouseEnter

I'm trying to have a simple html table, that highlights a row as a user mouses over it. Unfortunately the css hover item doesn't work for IE. That leaves me to simulate it in Javascript. I can use either onmouseenter or onmouseover.

What is the difference between them, and which one should I use?

Upvotes: 60

Views: 58123

Answers (3)

Chetan S
Chetan S

Reputation: 23813

Both onmouseenter and onmouseover fire when the mouse enters the boundary of an element. However, onmouseenter doesn't fire again (does not bubble) if the mouse enters a child element within this first element.

Upvotes: 89

djn
djn

Reputation: 3948

You might spare yourself some coding by just adding :hover support for all elements in IE too:
try csshover.htc

Upvotes: 1

Arkadiusz Kondas
Arkadiusz Kondas

Reputation: 474

Unlike the onmouseover event, the onmouseenter event does not bubble. In other words, the onmouseenter event does not fire when the user moves the mouse pointer over elements contained by the object, whereas onmouseover does fire.

I always use onmouseover. I use onmouseover in the same purpose (highlights a row).

Upvotes: 10

Related Questions