Here is part of my table
<table>
<tr>
<td>jack</td>
<td>20</td>
<td>450</td>
</tr>
<tr>
<td>james</td>
<td>20</td>
<td>450</td>
</tr>
<tr>
<td>john</td>
<td>20</td>
<td>450</td>
</tr>
</table>
My jQuery code looks like this
var toShow = [
"jack",
"john"
];
var addClass = [
"jack"
];
$('tr:contains(toShow)').remove();
$('tr:contains(addClass)').addClass("done");
The goal is compare toShow array with my table. If string doesn't not exist, remove tr element with it. If my table matches item from addClass than add class.
Im not sure why my code do not works. Result shoud be remove last tr element from table and for first add class .done
removeto values insidetoShowarray...var addClass = [ "james" ];if you want to see anything with a "done" class