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

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

No Reader comments



Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.