JSFiddle - React, Tailwind, and code Playground

by Michael Perrenoud

HTML

<button onClick="add()">Add</button>

<input type="text" placeholder="Enter the index to remove"/>
<button onClick="remove()">Remove</button>

<fieldset id="set">

</fieldset>

JavaScript

function add() {
	const fieldSet = document.querySelector('#set');
	const input = fieldSet.children.append('input');
  input.id = `index${fieldSet.children.length}`;
  input.innerHTML = `Index ${fieldSet.children.length}`;
}