且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 jQuery 插入表格列

更新时间:2023-11-30 20:01:10

试试这个:

$(document).ready(function(){
    $('table').find('tr').each(function(){
        $(this).find('td').eq(0).after('<td>cell 1a</td>');
    });
});

您的原始代码会将列添加到每行的末尾,而不是列之间.这将找到第一列并在第一列旁边添加单元格.

Your original code would add the column to the end of each row, not in between columns. This finds the first column and adds the cell next to the first column.