如我有
<div onmouseout='alert("")'>
    ......
</div>
里面的....是有其他的内容
但是当我的鼠标移动其他的内容但是他还在div内部的时候他也会执行onmouseout
没有没哪个方法是计算鼠标真实的离开的事件啊谢谢

解决方案 »

  1.   

    你可以 判断event.toElement是不是div 或div的里面
    不是的话那就是真的离开了div 
    判断是不是是不是div 或div的里面可以用contains 
      

  2.   


    应该是这样啊,在层上是 onmouseover 事件,离开层的后是 onmouseout 事件估计你alert弹出提示是在层外了,移开鼠标去点确定就会不断触发 onmouseout 事件
      

  3.   

    LS你试试在LZ的DIV里写个INPUT就知道他说什么了.通过TOELEMENT计算其是否在层内吧...
      

  4.   


    $(".menu ul li ul div").mouseout(function(event)
        {
            $("#divMsg").text(this.contains(event.toElement));
        })移动他里面的控件还是会提示出false怎么办啊
      

  5.   

    $(".menu ul li ul div").mouseout(function(event)
        {
            if(this==$(event.toElement).parent("div").get(0))event.cancelBubble();
        })
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <div id="a" style="padding:50px; border:1px solid #000;">
    <div style="border:1px solid #000; width:50px; height:50px;">
    </div>
    </div>
    <div id="s"></div>
    <script type="text/javascript">
    var o = document.getElementById("a");
    o.onmouseout=function()
    {
        document.getElementById("s").innerHTML+=this.contains(event.toElement);
    }</script>
    </body>
    </html>
    自己试试