<div id="d1" onmouseover="(打开d2)" onmouseout="(关闭d2)">
 
     <div id="d2">你好</div></div>
我鼠标移动到d1层上 d2的内容一闪就过了 好像是触发了 d1 的onmouseout有没有办法 鼠标移动到D2上面的时候 不关闭 只有鼠标移到d1外才触发 onmouseout

解决方案 »

  1.   

    两次div的位置都完全重叠了,不可能会出现只触发一个div的事件而不会触发另外一个div的事件的。
      

  2.   

    你的d2覆盖了d1,看下边的例子:<!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=utf-8" />
    <title>无标题文档</title>
    <script language="javascript">
    function openD2(evt)
    {
    document.getElementById("d2").style.display="";
    }
    function closeD2(evt)
    {
    document.getElementById("d2").style.display="none";
    }
    </script>
    <style type="text/css">
    <!--
    #d1 {
    position:absolute;
    left:127px;
    top:103px;
    width:362px;
    height:179px;
    z-index:1;
    background-color: #003333;
    }
    #d2 {
    position:absolute;
    left:93px;
    top:65px;
    width:202px;
    height:90px;
    z-index:1;
    background-color: #CCCCCC;
    }
    -->
    </style>
    </head><body>
    <div id="d1" onmouseover="openD2()" onmouseout="closeD2()"> 
      <div id="d2">你好</div>
    </div>
    </body>
    </html>
      

  3.   

    首先是你的两个DIV互相盖了,就像楼上说的。
    其次楼上这样虽然看不出有什么不正常,但是因为事件冒泡的问题,其工作方式可能并不是你想要的那样。
    把代码改成这样试试就可以看出问题来了
    function openD2(evt)
    {
        document.getElementById("d2").style.display="";
        alert("open");
    }
    function closeD2(evt)
    {
        document.getElementById("d2").style.display="none";
        alert("close");
    }避免这个问题可以去搜索一下“阻止事件冒泡”
      

  4.   

    能不能整个例子讲讲如何阻止冒泡?http://wenwen.soso.com/z/q341405385.htm