Clone a hidden template

Keep one hidden row as the pattern and clone it every time the user clicks Add.

jQuery · Clone a hidden templateBeginner
$('#add-row').on('click', function () {
  const $row = $('#row-template').clone().removeAttr('id').removeClass('d-none').show();
  $row.find('input').val('');
  $('#rows').append($row);
});

$('#rows').on('click', '.remove-row', function () {
  $(this).closest('.row-item').remove();
});
clonetemplateadd rowform