2016-04-04 48 views
0
<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?

回答

3

您可以使用包含選擇:

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

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