简体   繁体   English

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

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

<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>

I want to show only this rows, which have 我只想显示这些行

<td>True</td> 

and additionally I want to remove "Show in table" column from finally html file. 另外我想从最终的html文件中删除“在表中显示”列。 How can I do it in jquery or javascript? 如何在jquery或javascript中做到这一点?

You can use contains selector: 您可以使用包含选择器:

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

and

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM