I have a table with many rows . first row is the header.
i want to delete all the rows if any of its td does not have given text.
<tr>
<td id="1" class="links">Madia</td>
<td id="" class="edit_client" >Press</td>
</tr>
<tr>
<td id="2" class="td_link" >Nagara </td>
<td class="td_link" id="11" class="edit_client">KR Pura</td>
</tr>
I want to delete all the tr , if any of its td does not have given text say "me hussy".
$('tr').each(function () {
});
i do not want delete first row because its header. so function should check from second row onwards.
Try doing this
$('table tr:gt(0)').each(function() {
if ($('td:contains("me hussy")', this).length == 0) $(this).remove();
});
Demo on jsFiddle.net
EDIT:
Thanks mesiesta for :gt(0)
EDIT
With respect to OP's comment
var name = "me hussy";
$('table tr:gt(0)').each(function() {
if ($('td:contains("'+ name +'")', this).length == 0) $(this).remove();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With