I want to iterate through each cell in each row in a table id=”myTable” and get the ids of the cells’ child divs.
So far I have something like:
$("td.theCell").each(function() {
var id = $(this).attr('id'); //this would give me the td id but I want its child div's id
});
my html is like:
<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>
Does anybody know a good way to do this? Thanks in advance.
Try this
You need to get the Id of the div and not the td.thecell element right.
So you need to use
.find()to select the dive inside it..