js
window.onload=function() { var Div1=document.getElementById("div1"); var Div2=document.getElementById("div2"); var time; Div2.onmouseover=Div1.onmouseover=function() { clearTimeout(time); Div2.style.display="block"; } Div2.onmouseout=Div1.onmouseout=function() { time=setTimeout(function(){ Div2.style.display="none"},500); } // Div2.onmouseover=function(){ // clearTimeout(time); // Div2.style.display="block"; // } // Div2.onmouseout=function() // { // time=setTimeout(function(){ // Div2.style.display="none"},500); // } }css
*{ padding: 0px; margin: 0px; } div{ margin: 10px; } #div1{ width: 40px; height: 50px; background:skyblue; float:left; } #div2{ width: 40px; height: 100px; background: palegreen; float:left; display: none; }