If you are using jQuery, use mouseenter and mouseleave instead of mouseover and mouseout .

If you take the example above, everything inside the border is an element, let it name the word βNameβ in it #A. mouseenter will only fire when moving the mouse inside the border #A. mouseover on the other hand, will fire when you enter the frame, again when you move the mouse past the gray background behind β1β, and again when you hover over the word βNameβ. If you want the event to fire once, use mouseenter .
source share