Untitled

 avatar
unknown
plain_text
2 years ago
495 B
5
Indexable
$(document).ready(function() {
    var i = 0;
    $('.add-item').on('click', function() {
        var item = $('#item-template').clone();
        item.find(':input').each(function() {
            var name = $(this).attr('name').replace('index', i);
            $(this).attr('name', name);
        });
        $('#items-container').append(item);
        i++;
    });

    $(document).on('click', '.remove-item', function() {
        $(this).closest('.item').remove();
    });
});
Editor is loading...