Javascript:获取 table 单元格的内容(在 div 内)

Javascript: get content of table's cell (inside div)

我在查找单元格 ID(及其内容)时遇到了一点问题。 Main table 包含多个分区,每个分区包含一个 table 和多个单元格。我想要的是显示 ID 为 content_xx 的单元格。我的 table 看起来像这样:

<table id="MainTable">                  // Main (global) table

 <div id="divid_1">                     // First div in main table
  <table id="InfoTable">                // First div's table
   <td id="title_10">CellTitle</td>     // Cell #1
   <td id="content_11">CellContent</td> // Cell #2

 <div id="divid_2">                     // Second div in main table
  <table id="InfoTable">                // Second div's table
   <td id="title_20">CellTitle</td>     // Cell #1
   <td id="content_21">CellContent</td> // Cell #2

 // etc...
</table>

查找函数:

function FindContent(id)
{
    t = document.getElementById("InfoTable").rows[0].cells.namedItem("content_"+id).innerHTML;
    alert(t);
    return;
}

我有执行此功能的 onclick 事件。它只适用于第一个 InfoTable,但当我在 table #2 或更远的地方尝试同样的事情时它不起作用。我收到此错误:TypeError: document.getElementById(...).rows[0].cells.namedItem(...) is null。我该如何解决这个问题以及为什么它不起作用?是因为row[0]吗?例如,如果我更改为 row[1],则它根本不起作用。我可以更改 html 的结构,但不能完全更改。

** 由 icecub 解决**

问题是我在 div 中使用相同的 ID,因此,只会返回第一个 table。我只需要使用不同的 ID。