鼠标动作捕获与响应界面图如几个图所示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>鼠标事件</title>
<style>
.global{
width: 400px;
height: 400px;
background: chartreuse;
text-align: center;
margin: 0 auto;
margin-top: 10px;
padding: 10px;
}
img{
margin-top: 20px;
}
input{
height: 30px;
width: 200px;
}
hr{
color: white;
}
</style>
<script>
function $(id){
return document.getElementById(id);
}
function mouseOver(){
$("image").src="img/image21.jpg";
$("input-text").value="鼠标在图上";
$("global").style.background="green";
}
function mouseOut(){
$("image").src="img/image22.jpg";
$("input-text").value="鼠标不在图上";
$("global").style.background="blue";
}
function Click(){
$("image").src="img/image23.jpg";
$("input-text").value="鼠标单击";
$("global").style.background="yellow";
}
function dblclick(){
$("image").src="img/image24.jpg";
$("input-text").value="鼠标双击";
$("global").style.background="orange";
}
</script>
</head>
<body>
<div class="global" id="global" onmouseover="mouseOver()" onmouseout="mouseOut()" ondblclick="dblclick()" onclick="Click()">
<h1> 鼠标动件捕获与响应</h1>
<hr>
<input type="text" id="input-text">
<img src="img/image21.jpg" alt="" id="image" >
</div>
</body>
</html>