Mouseleave
For issues relating to setting up, subscribing to, or handling mouseleave events.
Mouseover
A mouseover is an event that occurs on an element when the user moves the cursor over that element
Reliable
Example |
---|
"Also you might want to use mouseenter and mouseleave which are sanitized by jquery and are a little more reliable than mouseover and mouseout" from question Document.getElementById('id') problems "Imho mouseenter and mouseleave are much more reliable than mouseover and mouseout which tend to flicker" from question Creating onmouseover function for separate div |
Others
Example |
---|
In this case mouseenter mouseleave has better behaviour and prevents bubbling compared to mouseover mouseout from question Mouseleave on a container with a select - Internet Explorer 10 It should also be noted that mouseenter and mouseleave work somewhat differently and usually much better than mouseover and mouseout from question What is the shorthand for this? |
Try this instead or to make use of jquery to reduce code you could simply do this mouseover will cause this to fire every time the mouse moves one pixel over the element so this could result in rapid flashing you may want to use the mouseenter and mouseleave to have better control over this behavior;the problem is that you are assigning the result of the function to the mouseover event not the function itself from question Simple Function Not working in Javascript |