JavaScript
Article
By Sam Deering

jQuery remove table column (by column number)

By Sam Deering

Simple jQuery code snippet to remove an entire table column based on the column number. It also removes the table row heading associated with the removed column.

//remove the 1st column
$('#table').find('td,th').first().remove();

//remove the 1st column
$('table tr').find('td:eq(1),th:eq(1)').remove();

//remove the 2nd column
$('table tr').find('td:eq(1),th:eq(1)').remove();

//remove the nth column
$('table tr').find('td:eq(n),th:eq(n)').remove();
Recommended
Sponsors
Get the latest in JavaScript, once a week, for free.