Mayhem: onMouseOver onMouseOut with div

2.3k Views Asked by At

Imagine moving your mouse left to right across this webpage fragment:

enter image description here

The gray box is a DIV. I want a single onMouseOver when mousing into it, and a single onMouseOut when exiting it.

What I actually get (left to right):

onMouseOver DIV
onMouseOut DIV
onMouseOver Flag
onMouseOut Flag
onMouseOver DIV
onMouseOut DIV
onMouseOver USA
onMouseOut USA
onMouseOver DIV
onMouseOut DIV
onMouseOver 2
onMouseOut 2
onMouseOver DIV
onMouseOut DIV

Whew!

How can I just get a single onMouseOver and onMouseOut for the container DIV?

1

There are 1 best solutions below

0
On BEST ANSWER

Quirksmode has a wonderful article on this.

Although if you feel like using jQuery you can use mouseenter and mouseleave events.