JSFiddle - React, Tailwind, and code Playground

HTML

<h2>Instructions:</h2>Click inside yellow div to make new field appear.<br>Then, click button to get value of that field's name attribute.<br><br>
<div id="form1"></div>
<input type="button" id="mybutt" value="Get Attr=Name of New Input Field">

CSS

div{width:40%;height:80px;background:wheat;}

JavaScript

var id = "Hello";

$('#form1').click(function(){ //listen for submit event
    $(this).append('<input name="' +id+ '" type="text" />');
});

$('#mybutt').click(function() {
    var test = $('input:not(button)').attr('name');
    alert(test);
});