<div class="Default_ull" id="Default_ull" onmouseover="mouserOverDefault();">
                            <div style=" float:left; width:78px; height:28px; margin-top:12px; cursor:pointer; margin-left:5px; background-color:Red;"></div>
                            <div style=" float:left; width:70px; height:28px; margin-top:12px; cursor:pointer; margin-left:-1px; background-color:Black; "></div>
                            <div style=" float:left; width:70px; height:28px; margin-top:12px; cursor:pointer; margin-left:-1px;"></div>
                            <div style=" float:left; width:70px; height:28px; margin-top:12px; cursor:pointer; margin-left:-1px;"></div>
                            <div style=" float:left; width:70px; height:28px; margin-top:12px; cursor:pointer; margin-left:-1px;"></div>
                            <div style=" float:left; width:71px; height:28px; margin-top:12px; cursor:pointer; margin-left:-1px;"></div>
                        </div>
这是一小段页面的代码    当我鼠标移动到Default_ull 这个div上面的时候回触发mouserOverDefault事件
但是当我鼠标移动到内部的那些div上面的时候 还是会触发mouserOverDefault事件  我该怎么样做才能避免移动到内部div时不触发mouserOverDefault事件呢??

解决方案 »

  1.   

    可以把两个部份分开.然后放在一个DIV里..
      

  2.   

    什么意思?  两个部分分开??? 如何分开  内部的那些小的div是必须存在这个div里面的啊
      

  3.   

    为里面不需要触发mouseover的div加上
    onmouseover = function()
    {
    event.returnValue=false;
    event.cancelBubble=true;
    return false;
    }
      

  4.   

    DOM 事件冒泡机制dom触发事件后 默认会象父级传递 引起链式触发 
    可以取消事件的冒泡 或者在事件中检查 触发事件的对象 是否允许执行这个事件去检索一下 这个主题
      

  5.   

    onmouseover = function(e) {
        var e = e || window.event;
        e.stopPropagation && e.stopPropagation() || (e.cancelBubble = true);
    }
      

  6.   


    function mouserOverDefault(evt) {
                var e = (evt) ? evt : window.event; //判断浏览器的类型,在基于ie内核的浏览器中的使用cancelBubble
                if (window.event) {
                    alert(1111);
                    e.cancelBubble = true; ;
                } else {
                    //e.preventDefault(); //在基于firefox内核的浏览器中支持做法stopPropagation
                    e.stopPropagation();
                }
                alert();
                document.getElementById("Default_ull").style.backgroundImage = "url(Images/10.png)";
            }这是onmouseover触发的方法  我已经阻止冒泡事件  但是在断点调试的时候    发现内部div还是触发mouserover事件
      

  7.   

    给你一个例子,你看看是不是这个意思: <script src="JS/jquery-1.4.4.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function() {
                $(document).mouseover(function(event) {
                    if (event.target.id == "test1") {
                        alert("Test1");
                    }
                    if (event.target.id == "test2") {
                        alert("test2");
                    }
                });
            });
        </script>
    <div id="test1" style="background-color:Red;width:100px;height:50px">
            <div id="test2" style="background-color:Blue;width:50px;height:25px"></div>
        </div>
      

  8.   

    楼主真有意思,你外部DIV里的内容全是由内部DIV构成,内部DIV都不需要onmouseover事件,你又何必在外部DIV添加这个事件。哪个层需要onmouseover事件你就在哪里添加就是了
      

  9.   

    http://blog.csdn.net/hch126163/archive/2010/02/08/5298791.aspx
      

  10.   

    冒泡事件的顺序不同的浏览器是不一样的。另外,我觉得楼主这个问题好像又问题。你的内部div在外部的div内,你怎么把鼠标移动到内部的div上而不移动到外部的div上呢?
    比如,你想进卧室,而不进你家,那怎么可能?在卧室里,你就已经在你家里了