For example, if I do $('div#something').mouseout(function(){});
then the function will fire when I hover on text that is inside the #something div instead of when I leave the div.
I want it 开发者_Python百科to fire only when I leave the div, not when I hover over text inside the div.
Why is this happening?
mouseout fires whenever the mouse cursor leaves an element, even if "leaving" means it is entering a child element (which the text would be - at least on some browsers).
You may want to use "mouseleave" instead.
http://api.jquery.com/mouseleave/
mouseOut fires when the mouse leaves an element - and that includes when it moves onto its child elements. See this jsFiddle: http://jsfiddle.net/minitech/kZcCr/
精彩评论