很明显的错误id重复了,改为name,引用时var cld=document.getElementsByName("child")

解决方案 »

  1.   

    id是唯一的
    <html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>5</title>
    <style type=text/css>
    .c1  {position: absolute;font-size:11pt;font-weight: bold;line-height: 14pt;color:#ff0000;font-family:宋体} 
    .c2  {position: absolute;font-size:9pt;line-height:12pt;color:yellow;}
    .c3  {position: absolute;font-size:9pt;line-height:12pt;color:blue;}
    .d1  { position:absolute; left: 35px; display:none;width: 170px;font-size:9pt;line-height:12pt;color:blue;}
    a:link {text-decoration: none;}
    a:visited {text-decoration: none;color:#ff0000}
    a:active {text-decoration: underline;}
    a:hover {text-decoration: underline;}
    </style>
    </head><body>
    <script>
    function hideAll() {
      for(i=0;i<6;i++) {
        eval("child"+i).style.display="none";
      }
    }function showObj(num)  {
    if (eval("child"+num).style.display=="none")
    {
    hideAll();
    eval("child"+num).style.display="block";
    }
    else {
        eval("child"+num).style.display="none";
      }
    }
    </script>
    <table border="1">
    <tr>
    <td> <img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
          <a href="#" onclick="showObj(0)">111</a><br>   
      <div id="child0" class="d1"> 
            <A HREF="9.htm" target="data">1111</A><BR>
            <A HREF="10.htm" target="data">1111</A><BR>
            <A HREF="11.htm" target="data">1111</A><BR>
            <A HREF="12.htm" target="data">11</A><BR>
            <A HREF="13.htm" target="data">11</A><BR>
            <A HREF="14.htm" target="data">11</A><BR>
          </div>
      </td>
      </tr>
    <tr>
    <td><img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
          <a href="#" onclick="showObj(1)">22</a><br>   
      <div id="child1" class="d1"> 
      <A HREF="15.htm" target="data">22</A><BR>
      <A HREF="16.htm" target="data">22</A><BR>
      </div>
      </td></tr>
      <tr>
      <td>
    <img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
          <a href="#" onclick="showObj(2)">33</a><br>   
    <div id="child2" class="d1">
      <A HREF="15.htm" target="data">33</A><BR>
      </div>
      </td></tr>
      <tr><td>
    <img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
          <a href="#" onclick="showObj(3)">44</a><br>      
      <div id="child3" class="d1">
            <A HREF="9.htm" target="data">44</A><BR>
            <A HREF="10.htm" target="data">44</A><BR>
            <A HREF="11.htm" target="data">44</A><BR>
    </div>
    </td></tr>
    <tr><td>
     <img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
    <a href="#" onclick="showObj(4)">55</a><br>   
    <div id="child4" class="d1">
      <A HREF="21.htm" target="data">55</A><BR>
       <A HREF="22.htm" target="data">55</A><BR>
      <A HREF="23.htm" target="data">55</A><BR>
       <A HREF="24.htm" target="data">55</A>
     </div>
    </td></tr>
    <tr><td>
     <img src="new/close.gif" id="img1" width="9" height="16" border="0" name="img1"> 
    <a href="#" onclick="showObj(5)">66</a><br>   
    <div id="child5" class="d1">
      <A HREF="25.htm" target="data">66</A><BR>
    </div>
    </td></tr>
    </table>
    </body>
    </html>