user160820
user160820

Reputation: 15220

onmouseout event control

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?

Upvotes: 1

Views: 308

Answers (2)

Kissaki
Kissaki

Reputation: 9237

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

Upvotes: 0

Kissaki
Kissaki

Reputation: 9237

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.

Upvotes: 1

Related Questions