代码
<!doctype html>标签:scale,1.0,示例,dog,修改,鼠标悬停,querySelector,var,document From: https://blog.51cto.com/u_13137233/6047095
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button id="y">狗1</button>
<button id="b">狗2</button>
<div class="box">
<img id="dog" style="width: 200px;" src="https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF" alt="">
</div>
<script>
var b1 = document.querySelector("#y")
var b2 = document.querySelector("#b")
var dog = document.querySelector("#dog")
b1.onmouseenter = function () {
dog.src = "https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF"
}
b2.onmouseenter = function () {
dog.src = "https://t7.baidu.com/it/u=1951548898,3927145&fm=193&f=GIF"
}
</script>
</body>
</html>