当鼠标移到图像上时,我想放大图像,然后将其恢复正常。使用我的 JavaScript 中的 getPhoto 函数可以正常大小地加载图像,但是当我将鼠标悬停在它上面时,什么也没有发生。
我究竟做错了什么?
document.getElementById("photo").onmouseover = function() {
mouseOver()
};
document.getElementById("photo").onmouseout = function() {
mouseOut()
};
function getPhoto(handle) {
var img = new Image();
var div = document.getElementById("photo");
while (div.firstChild) {
div.removeChild(div.firstChild);
}
img.src = "https://res.cloudinary.com/harmhxmnk/image/upload/" + handle;
img.height = 32;
img.onload = function() {
div.appendChild(img);
};
}
function mouseOver() {
var img = document.getElementById("photo");
img.height = 100;
}
function mouseOut() {
// TODO
}
.photo {
position: absolute;
top: 86px;
right: 92px;
}
<div class="photo" id="photo"></div>