[英]Select appropriate tr in table - jquery
How can I select the tr tag containing USDTRY value in its second td and change its value with TRYUSD using jquery? 如何在第二个td中选择包含USDTRY值的tr标签,并使用jquery用TRYUSD更改其值?
<table class="k-selectable" cellspacing="0" role="grid" data-role="selectable">
<tbody>
<tr role="row" data-uid="9d1c0ae7-ec5d-4377-ad61-9eace8158802">
<td role="gridcell">
<img src="/Images/up.png">
</td>
<td role="gridcell">USDTRY</td>
<td role="gridcell">1.30514</td>
<td role="gridcell">1.30527</td>
</tr>
<tr class="k-alt" role="row" data-uid="0ff48da9-2019-4cf8-b631-a09c3ce98d63">
<tr role="row" data-uid="2c9ae0ba-c744-4bbb-9a23-fd15a3b65b6c">
</tbody>
您想使用常规选择器尽可能缩小选择范围,然后可以使用:contains
psuedoselector搜索文本:
$('table.k-selectable td:contains("USDTRY")').text('TRYUSD');
Perhaps not a perfect solution, but try this: 也许不是一个完美的解决方案,但是请尝试以下操作:
$('table.k-selectable tr td').each(function() {
if($(this).text() === 'USDTRY') {
$(this).text('TRYUSD');
}
});
$(selector).find("tr:contains('USDTRY ')");
要么
$('tableId td:contains("USDTRY")').text('TRYUSD ');
使用包含选择器:
$('td:contains("USDTRY")').html('TRYUSD ');
you don't need to find tr
..just find td
with that text using filter()
and replace 您不需要找到tr
..只需使用filter()
使用该文本找到td
并替换
$('td').filter(function(){
return $(this).text() == "USDTRY";
}).text('TRYUSD');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.