March 23, 2011
(jQuery) How to delete all cell from this table?
Question by l2aelba
<table class="Table">
<thead class="thead">
<tr class="tr">
<th class="th header">Done</th>
<th class="th header">None</th>
<th class="th header">None</th>
<th class="th header">Done</th>
<th class="th header">None</th>
<tr>
<td>info</td>
<td>info</td>
<td>info</td>
<td>info</td>
<td>info</td>
</tr>
</tr>
</thead>
</table>
I want to delete all “None”s cell and all “info” of cells
Any idea ? Thanks
Answer by Furqan
use this
$(".th:contains('None')") .remove();
$("td:contains('info')") .remove();
Your jsFiddle has been updated.
Answer by Starx
I think you are looking for this
$("th:contains('None')").each(function(index,value) {
//Grab all the "None" th and their indexes
$("tr td:nth-child("+$(this).index()+")").remove();
//remove the td with the same indexes on the next tr
$(this).remove();
// now also remove the "None" th
});
Here is your Solution