JSFiddle - React, Tailwind, and code Playground
HTML
<form>
Name: <input type="text" id="test-0" class="test"/>
</form>
JavaScript
var i = 0;
$(document).ready(function(){
$('.test').each(function(){
$(this).data('index', i);
i++;
});
$('#test-0').keyup(function(){
addInput($(this).data('index'));
});
});
function addInput(idx){
var next = idx + 1;
if($('#test-'+next).length <= 0){
$('form').append('<br/>Name: <input type="text" id="test-'+next+'" class="test"/>');
$('#test-'+next).data('index',next);
$('#test-'+next).keyup(function(){
addInput($(this).data('index'));
});
}
}