<body onload=aa()>
<table id="myTable">
  <tr>
    <td>
      <table id="firstHalf">
1
      </table>
    </td>
      <div>
        <table id="secondHalf">
2        
        </table>
      </div>
    <td>
    </td>
  </tr>
</table>
</bodY>
<script>
function aa()
{
var mytable = document.getElementById("myTable");
alert(mytable.childNodes[0].childNodes[0].childNodes[0].childNodes[0].id)
}
</script>

解决方案 »

  1.   

    用children也行<body onload=aa()>
    <table id="myTable">
      <tr>
        <td>
          <table id="firstHalf">
    1
          </table>
        </td>
          <div>
            <table id="secondHalf">
    2        
            </table>
          </div>
        <td>
        </td>
      </tr>
    </table>
    </bodY>
    <script>
    function aa()
    {
    var mytable = document.getElementById("myTable");
    alert(mytable.children[0].children[0].children[0].children[0].id)
    }
    </script>
      

  2.   

    用table的rows,cells也行
    <body onload=aa()>
    <table id="myTable">
      <tr>
        <td>
          <table id="firstHalf">
    1
          </table>
        </td>
          <div>
            <table id="secondHalf">
    2        
            </table>
          </div>
        <td>
        </td>
      </tr>
    </table>
    </bodY>
    <script>
    function aa()
    {
    var mytable = document.getElementById("myTable");
    alert(mytable.rows[0].cells[0].childNodes[0].id)
    }
    </script>