JSFiddle - React, Tailwind, and code Playground
HTML
<ul id="fields">
</ul>
<a href='#' onclick="createinput()">Click me!</a>
JavaScript
count = 0;
createinput =function (){
field_area = document.getElementById('fields')
var li = document.createElement("li");
var input = document.createElement("input");
input.id = 'field'+count;
input.name = 'field'+count;
input.type = "text"; //Type of field - can be any valid input type like text,file,checkbox etc.
li.appendChild(input);
field_area.appendChild(li);
//create the removal link
var removalLink = document.createElement('a');
removalLink.onclick = function(){
this.parentNode.parentNode.removeChild(this.parentNode)
}
var removalText = document.createTextNode('Remove Field');
removalLink.appendChild(removalText);
li.appendChild(removalLink);
count++
}