views:

24

answers:

2

I have a DIV with a mouseout observer.

This DIV have also child Elements. mouseout event will alse be fired if the mouse pointer enter any of its child elements.

How can I prevent this behavior?

+1  A: 

That’s expected behaviour. However you can prevent it by giving those child elements an onmouseout event as well and returning false. returning false in the event handler will stop the propagation of the event to parent-elements.

Kissaki
Sorry! but this will not prvent mouseout event occurence of it parent DIV.
Yeah, I reread your question and misunderstood it last time.
Kissaki
The mouseout will indeed fire if you're moving into the child div as well as when moving out of the child-div or parent div. As the child-div is a block on top of the parent div it will go out of the parent-div when moving over it, so that’s pretty much expected. To solve this the only solution that comes to mind is to create a function that’s called which checks for where the mouse is now.
Kissaki
You may want to check a JS library. JQuerys mouseleave function/event seems to be exactly what you’re looking for. The API page also states the mouseleave event is IE-proprietary but JQuery emulates it for other browsers. If you don’t want to use JQuery you may want to check their source. http://api.jquery.com/mouseleave/ (*adding as new answer now, as this answer is not wrong, but not on-problem or simple*)
Kissaki
A: 

You may want to check a JS library. JQuerys mouseleave function/event seems to be exactly what you’re looking for. The API page also states the mouseleave event is IE-proprietary but JQuery emulates it for other browsers. If you don’t want to use JQuery you may want to check their source. api.jquery.com/mouseleave

Kissaki