rselvaganesh rselvaganesh - 4 months ago 9
Javascript Question

jquery to select second row column using first row column <td> in table

I want to select second row second column using first row second column tag in html table

Example

<table>
<tr>
<td>Row 1</td>
<td id="amount-paid">$1.00 USD</td>
</tr>
<tr>
<td>Row 2</td>
<td>$2.69 USD</td>
</tr>
</table>


now i need to change the Row 2 second column value to "Paid" message.
This i need to do by using the first row second column id "amount-paid".

i tried the below code but it not worked

$('#amount-paid td:eq(2)').text('Paid');


It looks like this

Answer

Try following:

$('#amount-paid td:eq(1)').text('Paid');

How about these?

$('table tr:eq(1) td:eq(1)').text("Paid")

or

$('#amount-paid').closest('tr').next().find('td:eq(1)').text('Paid');
Comments