Mouseout parent element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nicodemas
    Recognized Expert New Member
    • Nov 2007
    • 164

    Mouseout parent element

    I am using jQuery to create a mouseout event on an element that contains many children.

    Code:
    <!-- simplified HTML -->
    <div id="wrapper">
       <div id="child-1">... some content...</div>
       <div id="child-2">... some content...</div>
    </div>

    Code:
    // simplified JavaScript
    $("#wrapper").mouseout(function(){
       alert("Hello World!");
    });
    So, as I move the mouse cursor over the wrapper and its children, as I move between the children, child-1 and child-2, the mouseout event of the parent is firing.

    Is this standard? I do not recall a mouseout event firing when you mouseover children of a parent. Is there something I am forgetting to do? Someone please freshen my memory.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    yes, this behaviour is standard since mouseover and mouseout capture/bubble. you can use the non-capturing/non-bubbling mouseenter and mouseleave instead.

    Comment

    Working...