JSFiddle - React, Tailwind, and code Playground

by SyedNizamChennai

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) {   
	console.log("hiii")
document.getElementById("divArea").removeChild(div.parentNode);
}

function addTextBox(value){		
    return '<input name="newTextBox" type="text" value = "' + value + '" />' +
            '<input type="button" value="Remove" onclick = "RemoveTextBox(this)" />'
}

document.getElementById('btnAdd').onclick = function() {
	var res = document.getElementById('val').value;  
  var div = document.createElement('DIV');
  div.innerHTML = addTextBox(res);
  document.getElementById("divArea").appendChild(div);
}