window.onload=init;function init(){ for(var i=0;i<document.links.length;i++) var linkobj=links[i]; if(linkobj.id){ var imgobj=document.getElementById(linkobj.id+"img"); } if(imgobj){ rollOver(linkobj,imgobj); } } function rollOver(thisLink,thisImage){ thisLink.imgToChange=thisImage; thisLink.onmouseout=function(){ this.imgToChange.src=this.outImage.src; } thisLink.onmouseover=function(){ this.imgToChange.src=this.overImage.src; } thisLink.outImage=new Image(); thisLink.outImage.src=thisImage.src; thisLink.overImage=new Image(); thisLink.overImage.src="images/"+thisLink.id+".jpg"; }补充html如下:<body><a href="#" id="hai">这是一个超链接</a><img src="images/海上日光.jpg" height="56" width="100" id="haiimg"></body>
添加回答
举报
0/150
提交
取消