我有这个脚本可以更改图像源 onmouseover/onmouseout。我现在添加了一些新元素,我想做同样的事情,但也会淡出,而不是立即更改图像源。有人可以给我一个提示,甚至可以更改我的代码吗?我会很感激的!
Javascript:
d004on = new Image(100, 100);
d004on.src = "images/catalog/dus004_h.png";
d004off = new Image(100, 100);
d004off.src = "images/catalog/dus004.png";
}
function change(imgName) {
if (document.images) {
imgOn = eval(imgName + "on.src");
document[imgName].src = imgOn;
}
}
function changeback(imgName) {
if (document.images) {
imgOff = eval(imgName + "off.src");
document[imgName].src = imgOff;
}
}
HTML:
<img src="images/catalog/dus004.png" alt="dus004" onMouseover="change('d004')" onMouseout="changeback('d004')"/>