为什么加上这句document.all("name" + i).scr;??

解决方案 »

  1.   

    <script>
    function xuanzhe()
    {
       for (i=2;i<13;i++)
       {
          alert("name" + i + " = images/pic" + i + "02" + ".gif");
          document.all("name" + i).scr="images/pic" + i + "02" + ".gif";
          document.all("name" + i).scr;
          document.all("name" + i).width="38";
       }
    }
    </script><img border="0" name="name1" onclick="javascript:xuanzhe()"  width="38" height="14">为何不行?
      

  2.   

    //如果“name“+i这些img元素存在,试试:
    <script>function xuanzhe()
    {
       for (i=2;i<13;i++)
       {
          alert("name" + i + " = images/pic" + i + "02" + ".gif");
          document.all("name" + i).scr="images/pic" + i + "02" + ".gif";
          //document.all("name" + i).scr;
          //下面一句也有可能是:document.all("name" + i).style.width
          document.all("name" + i).width="38";
       }
    }
    </script><img border="0" name="name1" onmouseup="javascript:xuanzhe()"  width="38" height="14">