我想遍历表 id="myTable" 中每一行中的每个单元格并获取单元格子 div 的 id。
到目前为止,我有类似的东西:
$("td.theCell").each(function() {
var id = $(this).attr('id'); //this would give me the td id but I want its child div's id
});
我的 html 是这样的:
<table id='myTable'>
<tr>foo</tr>
<tr>bar</tr>
<td>foo</td>
<td class='theCell'>
<div id='myDiv'>foo</div>
</td>
<tr>foo</tr>
<tr>bar</tr>
</table>
有人知道这样做的好方法吗?提前致谢。