[英]Get row from a table by td class and specific value in the cell in jquery
I want to find the row in multiple table which has specific value in a hidden td which has a class name 我想在具有类名的隐藏td中找到具有特定值的多个表中的行
<table>
<tr>
<td class="id hidden">16</td>
<td class="maintenance_date">30 Jun 2014</td>
<td class="station_code">TSK</td><td class="gear_code">T1</td>
<td class="role_name">INCHARGE SSE/SE</td>
</tr>
<table>
there will be multiple rows in the table or tables. 一个或多个表中将有多个行。 For Example, I want the rows with the text 16 only on the td which has class id hidden.
例如,我只希望在td上隐藏了类ID的文本行为16。
It's pretty simple: 很简单:
var searchTerm = 16;
var elements = $('td.hidden').filter(function() {
return $(this).text() == searchTerm;
}).parent();
You can use: 您可以使用:
var td16_row=$('td').filter(function(){
return $(this).text()=="16";
}).parent();
I think I would have done something like this (NOT tested) 我想我会做这样的事情(未经测试)
var elements = $("table tr").find(".id.hidden").html();
$.each( elements, function( key, value ) {
if (parseInt(value) === 16) {
//do something with $(this)
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.