gainsky
gainsky

Reputation: 175

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. How can I do it in jquery or javascript?

Upvotes: 0

Views: 117

Answers (2)

void
void

Reputation: 36703

// 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();

Upvotes: 1

Milind Anantwar
Milind Anantwar

Reputation: 82231

You can use contains selector:

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

and

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

Upvotes: 3

Related Questions