I have a table and cannot change markup:
<table>
<thead>
<tr>
<th>
blablabla
</th>
<th>
blablabla
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
efgd
</td>
<td>
efghdh
</td>
</tr>
</tbody>
</table>
Here is my function, which should delete a column. It is called on cell click:
function (menuItem, menu) {
var colnum = $(this).prevAll("td").length;
$(this).closest('table').find('thead tr th:eq('+colnum+')').remove();
$(this).closest("table").find('tbody tr td:eq('+colnum+')').remove();
return;
}
But it deletes something else, not the column I wanted to delete. Where am I wrong?