如何删除包含具有某些数据的单元格的表行?

时间:2016-04-04 09:16:18

标签: javascript jquery

<table>
<tr><th>Content</th><th>Show in table</th></tr>
<tr><td>ABC</td><td>True</td></tr>
<tr><td>ABC</td><td>False</td></tr>
</table>

我只想显示这些有

的行
<td>True</td> 

另外我想从最终的html文件中删除“Show in table”列。我怎么能在jquery或javascript中做到这一点?

2 个答案:

答案 0 :(得分:3)

您可以使用包含选择器:

$('tr:contains("Show in table")').remove();

$('tr:contains("True")').hide();

答案 1 :(得分:1)

// First removes the rows which have false in second column
$("tr").has("td:contains(False)").remove();

// Then remove the second column from the table.
$("table tr td:eq(1), table tr th:eq(1)").remove();
相关问题