<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>
利用js使图片变大
最新推荐文章于 2020-03-11 18:40:17 发布