I’m very new to JQuery and I want to ask if anyone know how to loop to this table using JQuery, get the first row id and change the fifth TD data
<table id="thisTable">
<thead>
</thead>
<tbody>
<tr id="45215">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Change This TD</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
</tbody>
<tbody>
<tr id="78955">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Change This TD</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
Thank you in advance.
I’m researching everywhere, but seem to be very confuse.
2
Answers
Inside loop using
$(this)
and:last
pseudo you can change yourtd
text.Or using
:nth-child
findtd:nth-child(5)
for 5th td and change your text.Example:
Use
tr:first-child
to get the first<tr>
and then use.find('td:nth-child(5)')
to get the 5th<td>
from this selected row.