猿问

求助js如何对多个图片进行作用

<div id="zuo3">
        <img name="img" onmouseover="bigger()" onmouseout="smaller()" src="img/1.jpg"
                style="cursor:pointer;width:100px;height:100px;" />
        <img name="img" onmouseover="bigger()" onmouseout="smaller()" src="img/2.jpg" 
                style="cursor:pointer;width:100px;height:100px;" />

<script type="text/javascript">
var img = document.getElementsByName('img');
 function bigger(){
  img.name.width = '200px';
  img.name.height = '200px';
 }

 function smaller(){
  img.name.width = '90px';
  img.name.height = '100px';
 }
</script>
    </div>

    这是我的网页里的代码 我想把鼠标移到图片上的时候,就对图片进行放大,但是不知道为什么这样做会报错 我没怎么学习过js 所以请求大神帮忙解决一下


扬帆大鱼
浏览 688回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答