So basically I want to change an image by passing over the mouse on a button. with the current code I am able to change the image when the button is clicked, but I also need it to change when I put the mouse over the button without having to click it. Any ideas?
<body>
<input type="button" class = "button" onclick="changeImage('https://www.gettyimages.es/gi-resources/images/500px/983794168.jpg')" value="button1" />
<img src="https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MXx8aHVtYW58ZW58MHx8MHw%3D&ixlib=rb-1.2.1&w=1000&q=80" class = "img" id="firstimage" width="310">
<input type="button" class = "button4" onclick="changeImage('https://images.unsplash.com/photo-1494548162494-384bba4ab999?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MXx8c3VucmlzZXxlbnwwfHwwfA%3D%3D&ixlib=rb-1.2.1&w=1000&q=80')" value="button2" />
and the javascript:
var image = document.getElementById('firstimage');
function changeImage(uri) {
image.src = uri;
}
question from:
https://stackoverflow.com/questions/66066164/how-can-i-change-an-image-by-hovering-a-button-more-details-below 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…