I am facing a rather awkward problem. I register two event handlers, one for mouseenter and one for mouseout for the li elements on the page. It has multiple div areas inside it. When I leave the li element it calls the out handler, which is ok. What is not ok is that the out handler is also triggered when I leave a div inside that li.
Below is an image that illustrates it. The blue area is the li element which I register an enter and out event for.
I tried to register handlers on the inner divs that would stop the propagation but it only results in the triggering of the out handler when I enter those inner divs.
Any idea what is going wrong here?
Use
mouseleaveinstead of mouseout.Mouseouttriggers everytime your mouse is going off from exactly atop of the target. So when you enter thedivs, your mouse goes out of theliand on the div. But it is still inside theLIof course, using mouseleave will make it work.From JQuery doc: