JSFiddle - React, Tailwind, and code Playground
HTML
<div id="divArea"/>
<input type="text" id="val"/>
<input type="button" id="btnAdd" value="Add"/>
JavaScript
var container = document.getElementById('divArea');
function RemoveTextBox(div) {
document.getElementById("divArea").removeChild(div.parentNode);
}
function addTextBox(value){
return '<input name="newTextBox" type="text" value = "' + value + '" />' +
'<input type="button" value="Remove" class="removeTxtBox" onclick = "RemoveTextBox(this)" />'
}
document.getElementById('btnAdd').onclick = function() {
var res = document.getElementById('val').value;
var div = document.createElement('DIV');
div.innerHTML = addTextBox(res);
container.appendChild(div);
}