In this below script, get all the td values of a Table in a JavaScript
Script:
$("#tblemp tbody tr").each(function() {
alert($(this).find("td:last-child").html());
});
HTML:
<table id="tblemp" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td class="details-control" ></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</td>
</tr>
</tbody>
</table>
$("#tblemp tbody tr").each(function() {
alert($(this).find("td:last-child").html());
});
HTML:
<table id="tblemp" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td class="details-control" ></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</td>
</tr>
</tbody>
</table>
No comments:
Post a Comment