Click here to Skip to main content
15,905,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a panel on my form.
I want to detect when the user enters my panel with his mouse and when
he leaves my panel.
If the user hovers a control inside my panel, I get the mouseleave,
which is understandable.
But how do I make the MouseLeave event fire only when the user moves the
cursor outside the panel and not when he hovers child controls of the panel?
Thanks
Posted

1 solution

Try like this ::
here is my two div section::
XML
<div  id="main">

    <div id="child">

    </div>

</div>


their css :
CSS
#main
{
color:orange;
text-align:center;
    width:400px;
    height:200px;
    background-color:#FF0000;
    float: left;
}
#child
{
color:orange;
text-align:center;
    width:200px;
    height:100px;
    background-color:#FF00FF;
}


and jquery function :

$(function(){
$("div#child").bind("mouseenter",function(){alert("child enter");});
$("div#child").bind("mouseleave",function(){alert("child leave");});

$("div#main").bind("mouseenter",function(){alert("parent enter");});
$("div#main").bind("mouseleave",function(){alert("parent leave");});

});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900