鼠标停在睁眼的图片上,图片会变成闭眼的效果
实现代码如下:
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script> | |
//睁眼 | |
function openEye(){ | |
var eye = document.getElementById("eye"); | |
eye.src = "img/eye01.jpg"; | |
} | |
//闭眼 | |
function closeEye(){ | |
var eye = document.getElementById("eye"); | |
eye.src = "img/eye02.jpg"; | |
} | |
</script> | |
</head> | |
<body> | |
<div onmouseover="closeEye()" onmouseout="openEye()" style="float: left;border: 1px solid #000000;"> | |
<img id="eye" src="img/eye01.jpg" width="200px" /> | |
</div> | |
</body> | |
</html> | |