🔥 Get 650+ Tech Books and Courses for $3/m for 3 months

jQuery remove table column (by column number)

Sam Deering
Share

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();