JSFiddle - React, Tailwind, and code Playground
HTML
<form id="dataFields" action="save.php">
<p>Feld 1 <input name="Feld1" type="text" size="30" maxlength="30"></p>
<p>Feld 2 <input name="Feld2" type="text" size="30" maxlength="30"></p>
</form>
<hr/>
<button id="newField">neues Feld</button>
<button id="eraseLast">letztes Feld löschen</button>
JavaScript
$('#newField').click(function(){
var countField = $('#dataFields p').length;
var newFNo = countField+1;
var childrenCount = $('#dataFields').children.length;
alert("children.length says "+childrenCount+" and length says "+countField);
var htmlData = '<p>Feld '+newFNo+' <input name="Feld'+newFNo+'" type="text" size="30" maxlength="30"/></p>';
$('#dataFields').append( htmlData);
});
$('#eraseLast').click(function(){
$('#dataFields p:last-child').remove();
});