时间:2021-07-01 10:21:17 帮助过:5人阅读
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="系统CSS初始化.css">
<style> #p1{ width: 50px; height: 50px; background: rebeccapurple; float: left; margin: 20px;
} #p2{ width: 200px; height: 200px; background: #555555; float: left; margin: 20px; display: none;
}
</style>
<script> window.onload=function () { var op1=document.getElementById("p1"); var op2=document.getElementById("p2"); var timer=null; op1.onmousemove=function () { clearTimeout(timer); op2.style.display="block";
} op1.onmouseleave=function () { timer= setTimeout(function ()
{ op2.style.display="none";
},500)
} op2.onmousemove=function () { clearTimeout(timer);
} op2.onmouseleave=function () { timer=setTimeout(function () { op2.style.display="none";
},500)
}
}
</script>
</head>
<body>
<p id="p1";></p>
<p id="p2"></p>
</body>
</html>以上就是JS的延时器 的详细内容,更多请关注Gxl网其它相关文章!