Blogger Information
Blog 250
fans 3
comment 0
visits 321190
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS--鼠标事件
梁凯达的博客
Original
843 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
			#box{width:100px;height:100px;background:pink;}
			#big{width:200px;height:200px;background:blue;display:none;margin-left:800px;}
	</style>
</head>
<body>
	<div id="box"></div>
	<div id="big"></div>
</body>
<script>
var  box = document.getElementById('box');
var  big = document.getElementById('big');
var timmer;
box.onmouseover = big.onmouseover = function (){
	// console.log('鼠标移入')
	// box.style.background="yellow";
	clearTimeout(timmer);
	big.style.display="block";
}

box.onmouseout = big.onmouseout = function(){
	// console.log('鼠标移除')
	// box.style.background="pink";
	timmer=setTimeout(function(){	
		big.style.display="none";
	},300);
}
// big.onmouseover = function(){
// 	big.style.display="block";
// }
// big.onmouseout = function(){
// 	big.style.display="none";
// }
</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		#parent{width:300px;height:300px;background:red;}
		#son{width:100px;height:100px;background:yellow;}
	</style>
</head>
<body>
	<div id="parent">
		<div id="son"></div>
	</div>
</body>
<script>
var parent = document.getElementById('parent');

parent.onmouseenter= function(){
	console.log('鼠标移入区域')
}
parent.onmouseleave = function(){
	console.log('鼠标移除区域')
}
</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post