There may be times when mouseout is a better choice than mouseleave .
For example, suppose you have created a tooltip that you want to display next to an item on the mouseenter . You use setTimeout to prevent the tooltip from popping up. You clear the timeout on mouseleave with clearTimeout , so if the mouse does not exit, a tooltip will not be displayed. This will work in 99% of cases.
But now let's say that the element to which you attach the tooltip has a button with a click event, and let's also assume that this button offers the user either a confirm field or an alert field. The user clicks the button, and the alert triggered. The user clicked it fast enough so that your tooltip didn't have the ability to pop up (so far so good).
The user clicks the OK button alert OK, and the mouse leaves the item. But since the browser page is now in a locked state, javascript will not light up until you mouseleave OK, which means your mouseleave WILL NOT FIRE event. After the user clicks OK, a tooltip pops up (which you don't need).
Using mouseout in this case would be a suitable solution because it works.
Darcy Jul 12 '11 at 15:54 2011-07-12 15:54
source share