<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
window.onload = function(){
//事件源.事件=function(){}
var pic = document.getElementById("pic");
//鼠标移动到图片上
pic.onmouseover = function(){
pic.src = "img/1.jpg";
}
//鼠标离开图片
pic.onmouseout = function(){
pic.src = "img/2.png";
}
}
</script>
</head>
<body>
<img src="img/2.png" id="pic" />
</body>
</html>
js 鼠标移动和离开
最新推荐文章于 2024-10-10 16:22:39 发布