触发显示和隐藏 div

 

 

 

 

  <script>
            window.onload = function(){
                var oDiv1 = document.getElementById("div1");
                var oDiv2 = document.getElementById("div2");
                var timer = null;
                oDiv1.onmouseover = function () {
                    clearTimeout(timer);
                    oDiv2.style.display = "block";
                }
                oDiv1.onmouseout = function(){
                    timer = setTimeout(function(){
                        oDiv2.style.display = "none";
                    }, 400);
                }
                oDiv2.onmouseover = function(){
                    clearTimeout(timer);
                    this.style.display = "block";
                }
                oDiv2.onmouseout = function(){
                    timer = setTimeout(function() {
                        oDiv2.style.display = "none";
                    }, 400);
                }
            }
        </script>

 

posted @ 2017-10-16 18:58  bingxingc  阅读(409)  评论(0编辑  收藏  举报