Reputation: 26008
I have a table with headers:
<table id="my-table">
<thead>
<th>header1</th>
<th>header2</th>
<th>header3</th>
</thead>
<tbody>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
</tr>
</tbody>
</table>
How do I select only rows and replace them with the new data using jQuery? Only rows and not headers.
Upvotes: 0
Views: 102
Reputation: 27738
It seems obvious, I would try this
$("#my-table tbody tr")
Or this
$("#my-table tr:has(td)")
Upvotes: 1
Reputation: 36531
try this
$('#my-table tbody tr td').each(function(){//to select all rows in the table with id my-table
$(this).text('test');
});
Upvotes: 1
Reputation: 4376
You could use the context of the jquery selector as well...
$("tr", "#my-table tbody").each(function (i, item) {
$("td", this).each(function () {
// do something with the td.
});
});
Upvotes: 1