JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<input name="+" type="button" id="+" onclick="addInput()" value="+" label="+" />
<input name="-" type="button" id="-" onclick="subtractInput()" value="-" label="-" />
</div>
JavaScript
var countBox = 1;
addInput = function() {
var breakNode = document.createElement("br");
breakNode.className = countBox.toString();
var input = document.createElement("input");
input.type = "text";
input.className = countBox.toString();
input.value = "#" + countBox.toString();
var container = document.getElementById('container');
container.appendChild(breakNode);
container.appendChild(input);
countBox += 1;
}
subtractInput = function() {
countBox -= 1;
// There will be 2 elements: 1 input, 1 br.
var elements = document.getElementsByClassName(countBox.toString());
var input = elements[1];
var br = elements[0];
input.parentNode.removeChild(input);
br.parentNode.removeChild(br);
}