欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

qq延时窗口学习

程序员文章站 2022-05-02 22:14:59
...

例一

<!DOCTYPE html>
<html>
<head>
	<title>js.xuexi</title>
	<style type="text/css">
		#div1{
			width: 300px;
			height: 50px;
			background: red;

		}
		#div2{
			margin-top: 10px;
			width: 200px;
			height: 20px;
			background: #ccc;
			display: none;
		}
	</style>
<script type="text/javascript">
	window.onload=function (){
		var oDiv1=document.getElementById('div1');
		var oDiv2=document.getElementById('div2');
		var timer=null;
		oDiv1.onmouseover=function show(){

			oDiv2.style.display='block';
			clearTimeout(timer);
		};
		function hide(){
			timer=setTimeout(function(){
				oDiv2.style.display='none';
			},300);
	
	
		};
		oDiv1.onmouseover=show;
		oDiv2.onmouseover=show;
		oDiv1.onmouseout=hide;
		oDiv2.onmouseout=hide;

	};

	
</script>
</head>
<body>
	<div id="div1">
		
	</div>
	<div id="div2">
		
	</div>
</body>
</html>

例二

在这里插入代码片

<!DOCTYPE html>
<html>
<head>
	<title>js.xuexi</title>
	<style type="text/css">
		#div1{
			width: 300px;
			height: 50px;
			background: red;

		}
		#div2{
			margin-top: 10px;
			width: 200px;
			height: 20px;
			background: #ccc;
			display: none;
		}
	</style>
<script type="text/javascript">
	window.onload=function (){
		var oDiv1=document.getElementById('div1');
		var oDiv2=document.getElementById('div2');
		var timer=null;
		oDiv1.onmouseover=function (){

			oDiv2.style.display='block';
			clearTimeout(timer);
		};
		oDiv1.onmouseout=function(){
			timer=setTimeout(function(){
				oDiv2.style.display='none';
			},300);
		oDiv2.onmouseover=function(){
			clearTimeout(timer);
		};
		oDiv2.onmouseout=function(){
			
			setTimeout(function(){oDiv2.style.display='none';},300)
		};	
		};
		

	};

	
</script>
</head>
<body>
	<div id="div1">
		
	</div>
	<div id="div2">
		
	</div>
</body>
</html>


 
相关标签: 前端学习

上一篇: css3动画

下一篇: 前端学习(二)