鼠标经过图片时换图片,同时图片放大。

html代码:

<div style="182px; height:182px; border:1px solid #FFF;">
<div id="img1" style=" margin:20px; ">
<img id="aboutusimg1" src="aboutUs/1.png" width="142" height="142" onmousemove="changeImagemove1()" onmouseout="changeImageout1()" />
</div>
</div>

js代码:

function changeImagemove1()
{
var element=document.getElementById("aboutusimg1");
element.width = "202";
element.height= "202";
element.src = "aboutUs/1-1.png";
document.getElementById("img1").style.margin="0";
}
function changeImageout1()
{
var element=document.getElementById("aboutusimg1");
element.src = "aboutUs/1.png";
element.width = "142";
element.height= "142";
document.getElementById("img1").style.margin="20px";
}

原文地址:https://www.cnblogs.com/leaflife/p/6735115.html