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.

--ADVERTISEMENT--

//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();
Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.