<!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="Имга1" alt="" class="img1" width="100" height="100">
</body>
<script>
let img = document.querySelector('.img1')
img.addEventListener('mouseover', function(){
if(img.getAttribute('src') === "Имга1"){
img.setAttribute('src', 'Имга2')
}
else{
img.setAttribute('src', 'Имга1')
}
})
img.addEventListener('mouseout', function(){
if(img.getAttribute('src') === "Имга1"){
img.setAttribute('src', 'Имга2')
}
else{
img.setAttribute('src', 'Имга1')
}
})
</script>
</html>