window.onload=rolloverInit;
function rolloverInit(){
for(var i=0;i<document.images.length;i++){
if(document.images[i].parentNode.tagName == "A"){
setupRollover(document.images[i]);
}
}
}
function setupRollover(thisImage){
thisImage.outImage = new Image();
thisImage.outImage.src = thisImage.src;
thisImage.onmouseout = function(){
this.src = this.outImage.src;
}
thisImage.overImage = new Image();
thisImage.overImage.src = "images/"+thisImage.id+"_2.jpg";
thisImage.onmouseover = function(){
this.src=this.overImage.src;
}
}
转载于:https://my.oschina.net/xtfjt1988/blog/135165