You do not need to select each cell of the table separately. You can select the columns of the source column and destination and iterate over them:
// Get the target column table cells. This will select the first cell from // each row in the table. var target = $('.grid tr td:first-child'); // Iterate over each cell in the source column and copy its text to the // corresponding cell in the target column. $('.grid tr td:nth-child(' + (col + 1) + ')').each(function (rowIndex) { target.slice(rowIndex, rowIndex + 1).text($(this).text()); });
source share