<!DOCTYPE HTML><html><head><meta charset = "utf-8"><title>无标题</title><style>div{ float:left;margin:10px;}#div1{width:50px;height:50px;background:red;}#div2{width:250px;height:180px;background:#ccc;display:none;}</style><script>window.οnlοad=function(){ var odiv1 = document.getElementById('div1'); var odiv2 = document.getElementById('div2'); var timer1 = null; var timer2 = null; odiv1.οnmοuseοver=function(){ clearTimeout(timer2); odiv2.style.display = 'block'; }; odiv1.οnmοuseοut=function(){ timer1 = setTimeout(function(){ odiv2.style.display='none'; },500); }; odiv2.οnmοuseοver=function(){ clearTimeout(timer1); }; odiv2.οnmοuseοut=function(){ timer2=setTimeout(function(){ odiv2.style.display = 'none'; },500); }; };
</script><body>
<div id="div1"></div><div id="div2"></div></body></html>
转载于:https://www.cnblogs.com/lize1215/p/7636434.html
相关资源:JS延时提示框实现方法详解