JSFiddle - React, Tailwind, and code Playground
by Carlos Montano
HTML
<form name="myForm" action="" method="POST">
<label for="PASIVOS">Ingreso de datos</label>
<div class="input_fields_wrap1">
<input class="add_field_button1" type="button" value="+ Agregar" />
</div>
<input type="submit" value="Enviar">
</form>
JavaScript
$(document).ready(function() {
var max_fields = Infinity; //maximum input boxes allowed
var wrapper1 = $(".input_fields_wrap1");
var add_button1 = $(".add_field_button1"); //Add button
var x = 1; //initlal text box count
$(add_button1).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper1).append('<div>Producto <input type="text" name="Producto[]"/> Precio <input type="text" name="Precio[]"/> Quantity <input type="text" name="Cantidad[]"/><a href="#" class="remove_field">Quitar</a></div>'); //add input box
}
});
$(wrapper1).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
});