且构网

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

使用jQuery从表中动态添加和删除行

更新时间:2023-12-05 07:50:46

这是您想要的吗? FIDDLE

Is this what you want? FIDDLE

     $('#container').on('click', '.survey_del', function() {
        var row = $(this).closest('tr');
        if (x >= 2) {
            x--;
        }
        var previous = $(row).prev('tr');
        $(previous).find('td.row-3').html("<input type='button' class='survey_del' style='float: right' value='-' id='del" + x + "'>");
        $(row).remove();
    });

然后将del按钮类重命名为survey_del.

And rename the del button class to survey_del.