MouseEnter和MouseLeave事件 [英] MouseEnter and MouseLeave event

查看:76
本文介绍了MouseEnter和MouseLeave事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的表格上有一个面板。

我想检测用户何时用鼠标进入我的面板以及

他离开我的面板。

如果用户在我的面板中悬停一个控件,我得到了mouseleave,

这是可以理解的。

但是,如果用户将

光标移动到面板外而不是当他将面板的子控件移动时,我怎么才能激活MouseLeave事件呢?

谢谢

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

推荐答案

试试这样::

这里是我的两个div部分::

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

    <div id="child">

    </div>

</div>





他们的css:



their 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;
}





和jquery函数:




and jquery function :


(function(){
(function(){


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


这篇关于MouseEnter和MouseLeave事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆