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

How to remove a table row that contains the cell with some data?

本文关键字:数据 单元格 何删除 删除 包含包      更新时间:2023-12-17
<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 文件中删除"在表格中显示"列。如何在jquery或javascript中做到这一点?

您可以使用包含选择器:

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

$('tr:contains("True")').hide();
// 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();