Sometimes you may get requirement to remove a column from a table or you may want to hide a column from a table. In both cases the logic is same just we have to use the .remove() method if we are interested to remove the column or use the .hide() method if we are interested to hide the column. Let’s have a look on how to do so
Row 2 Cell 1 | Row 2 Cell 2 |
Row 3 Cell 1 | Row 3 Cell 2 |
$("#removeButton ").click(function() { var $td = $(this).closest("td"); var index = $td.index() + 1; $td.closest("table").find("td:nth-child(" + index + ")").remove(); });Hopefully it will work for you.