views:

109

answers:

2

I'm trying to fire a function on the mouseout of a div. However when you mousover an element in the div it fires the mouseout.

<div id="my_div">
    <div class="another_div">X</div>
</div>

<script>
$("#my_div").mouseout(function () {
    alert('weeeee, I am out!');
}
</script>

This makes sense but how can I test for the mouseout event only if it is not on a child element?

+1  A: 

Try using the MouseLeave event rather than the mouseout, according to the API:

Mouseout fires when the pointer moves into or out from child element, while mouseleave doesn't.

Fermin
Same result as with mouseout.
ws0x9
@ws0x9, it should work .. you are doing something wrong ..your example with mouseleave : http://jsbin.com/emelu/2 works
Gaby