本篇文章介绍的内容是js的延时器的代码,现在分享给大家,有需要的朋友可以参考一下
<!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的延时器 的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号