jquery使用第一行列< td>来选择第二行列。在桌子里 [英] jquery to select second row column using first row column <td> in table

查看:391
本文介绍了jquery使用第一行列< td>来选择第二行列。在桌子里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在html表中使用第一行第二列< td> 标记选择第二行第二列。



示例:

 < table> 
< tr>
< td>第1行< / td>
< td id =已付金额> $ 1.00美元< / td>
< / tr>
< tr>
< td>第2行< / td>
< td> $ 2.69美元< / td>
< / tr>
< / table>

现在我需要将第2行的第二列值更改为付费 信息。
我需要使用第一行第二列ID amount-paid

我试过下面的代码但它不起作用:

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



$ b

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

这些如何?

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

  $('#amount-paid')。closest('tr ')的.next()找到(' TD:当量(1) ')文本(' 付费); 


I want to select second row second column using first row second column <td> 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');

解决方案

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');

这篇关于jquery使用第一行列&lt; td&gt;来选择第二行列。在桌子里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆