views:

645

answers:

4

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?

+1  A: 

Short answer: mouseenter more useful.

Explanation here: Mouse events.

NV
+1 for the quirksmode link, but mouseenter is IE only...
Victor
In this case, I've recomended use CSS :hover for good browsers and mouseenter for IE.
NV
+6  A: 

First of all, onmouseenter is IE-specific. Doesn't work in other browsers unless you use jQuery which can simulate this event.

Secondly, 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.

Chetan Sastry
+1  A: 

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

Arkadiusz Kondas
A: 

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

djn
css behaviors are waaaay slow. They run everytime a thread stops executing. Try adding some logging into the js from the htc to see this.If you're just tring to create a hover effect. We use :hover which works for everybody except IE6. Death to IE6. I think this is acceptable because hover effects are just a nice to have.
Juan Mendes