且构网

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

从发票页面添加/删除行

更新时间:2023-12-05 07:51:16

Use a common parameter like class or data-attrbiutes wherever possible. Common Ids are invalid.

Check this code,

$('#add').click(function () {
    var n = $('.row').length + 1;
    var temp = $('.row:first').clone();

    temp.attr('id', temp.attr('id') + n);       //avoiding duplicate ID

    $('input:first', temp).attr('placeholder', 'Item #' + n)
    $('.row:last').after(temp);
});

$(document).ready(function () {
    $("#remove").click(function () {
        $(".row:last").remove();               //Remove section.
    });
});

Demo

相关阅读

推荐文章