My HTML:
<div id="parent">
<div id="child">cx</div>
</div>
When I use jQuery
$('#parent').mouseout(function(){
//something here
});
I wonder why when my mouse enter the child div
the function fires. I'm still inside parent div
.
I want that mouseout
function to fire only when I leave the parent div
not when I'm on any child div
.
http://jsbin.com/esiju/ << example
Cheers
jQuery mouseout() MethodThe mouseout event occurs when the mouse pointer leaves the selected element. The mouseout() method triggers the mouseout event, or attaches a function to run when a mouseout event occurs.
The mouseout event is fired at an Element when a pointing device (usually a mouse) is used to move the cursor so that it is no longer contained within the element or one of its children.
The mouseup event is fired at an Element when a button on a pointing device (such as a mouse or trackpad) is released while the pointer is located inside it. mouseup events are the counterpoint to mousedown events.
The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.
This is what the mouseleave
event is for.
$('#parent').mouseleave(function(){
//something here
});
http://api.jquery.com/mouseleave/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With