[英]jQuery to dynamically change padding-top of first column in a table when image exists in the first row of the second column
[英]jquery to select second row column using first row column <td> in table
我想使用html表中的第一行第二列<td>
標簽選擇第二行第二列。
例:
<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>
現在,我需要將第2行的第二列值更改為“已付費 ”消息。 我需要通過使用第一行第二列ID“ amount-paid ”來完成此操作。
我嘗試了以下代碼,但是沒有用:
$('#amount-paid td:eq(2)').text('Paid');
請嘗試以下操作:
$('#amount-paid td:eq(1)').text('Paid');
這些怎么樣?
$('table tr:eq(1) td:eq(1)').text("Paid")
要么
$('#amount-paid').closest('tr').next().find('td:eq(1)').text('Paid');
使用jQuery .eq()
$('table tr').eq(1).find('td').eq(1).text('Paid');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table> <tr> <td>Row 1</td> <td>$1.00 USD</td> </tr> <tr id="amount-paid"> <td>Row 2</td> <td>$2.69 USD</td> </tr> </table>
嘗試使用innerHTML代替這樣的文本:
$('#amount-paid td:eq(1)')。innerHTML ='已付費';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.