简体   繁体   中英

Mayhem: onMouseOver onMouseOut with div

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

在此处输入图片说明

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?

Quirksmode has a wonderful article on this .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM