HTML中怎么使鼠标悬停在图片上,使图片变大?求代码解释。
3个回答
展开全部
<!DOCTYPE html>
<head>
<script>
window.onload = function(){
var img = document.getElementById("imgTest");
if (document.addEventListener){
img.addEventListener("mouseover",doMouseover,false);
img.addEventListener("mouseout",doMouseout,false);
}
else if(document.attachEvent){
img.attachEvent("mouseover",doMouseover);
img.attachEvent("mouseout",doMouseout);
}
else{
img.onmouseover = doMouseover;
img.onmouseout = doMouseout;
}
}
function doMouseover(){
this.width = this.width * 1.5;
this.height = this.height * 1.5;
}
function doMouseout(){
this.width = this.width / 1.5;
this.height = this.height / 1.5;
}
</script>
</head>
<body>
<img id = "imgTest" src = "img/barcode.jpg"/>
</body>
</html>
更多追问追答
追问
这好像只能改一张图片啊?怎么改多张?
追答
想实现什么效果能不能具体些?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |