<!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>Document</title>
</head>
<body>
<img src="./img/1.jpg" alt="" id="img">
<script>
document.querySelector('img').addEventListener('mouseout',function(){
this.src = './img/3.jpg'
})
document.querySelector('img').addEventListener('mouseover',function(){
this.src = './img/1.jpg'
})
</script>
</body>
</html>
事件处理:鼠标进入时显示一张图片,鼠标离开时显示另外一张图片,如此交替
最新推荐文章于 2025-03-15 22:56:15 发布