主要将事件对象放入第一个参数...
html中代码:
<img onmouseover="funX(event,'${pageContext.request.contextPath}/fileStore/${account.accountPicture}')"
onmouseout="funH()"
height="20px" src="${pageContext.request.contextPath}/fileStore/${account.accountPicture}">
function funX(event,img){
var e = window.event || arguments[0];
//alert(e.type);
//target = e.srcElement || e.target;
//alert(target.tagName);
var divImg = $("#div_img").get(0);
divImg.style.display="";
divImg.style.left=event.clientX+10;
divImg.style.top=event.clientY;
$("#div_img img").get(0).src=img;
}
function funH()
{$("#div_img").get(0).style.display='none';}
本文介绍了一种使用HTML和JavaScript实现鼠标悬停时显示完整尺寸图片预览的效果。通过监听mouseover事件并获取事件对象,调整预览图片的位置,为用户提供更好的视觉体验。
186

被折叠的 条评论
为什么被折叠?



