我试图复制一个图像交换,但是当我只希望它在最后一个时,鼠标移出最终在三个交换中的每一个上都是图像 3。任何帮助我弄清楚我如何使交换彼此不同,因此他们不会调用相同的图像,我将不胜感激,谢谢!
//---imageswap1
if(document.images) {
cars1 = new Array();
cars1[1] = new Image();
cars1[1].src = "car4.png";
cars1[2] = new Image();
cars1[2].src = "car1.png";
}
function swapping_pics(picture_name, value_2) {
document.images[picture_name].src = cars1[value_2].src;
}
//---imageswap2
if(document.images) {
cars2 = new Array();
cars2[1] = new Image();
cars2[1].src = "car5.png";
cars2[2] = new Image();
cars2[2].src = "car2.png";
}
//---imageswap3
function swapping_pics(picture_name, value_2) {
document.images[picture_name].src = cars2[value_2].src;
}
if(document.images) {
cars3 = new Array();
cars3[1] = new Image();
cars3[1].src = "car6.png";
cars3[2] = new Image();
cars3[2].src = "car3.png";
}
function swapping_pics(picture_name, value_2) {
document.images[picture_name].src = cars3[value_2].src;
}
<div id="imageswap1" onMouseOver="swapping_pics('car1',1)" onMouseOut="swapping_pics('car1',2)" href="javascript:void">
<img name="car1" border=”0” src="car1.png" alt="car1">
</div>
<div id="imageswap2" onMouseOver="swapping_pics('car2',1)" onMouseOut="swapping_pics('car2',2)" href="javascript:void">
<img name="car2" border=”0” src="car2.png" alt="car2">
</div>
<div id="imageswap3" onMouseOver="swapping_pics('car3',1)" onMouseOut="swapping_pics('car3',2)" href="javascript:void">
<img name="car3" border=”0” src="car3.png" alt="car3">
</div>