JSFiddle - React, Tailwind, and code Playground
HTML
<fieldset>
<div class="input_fields_wrap">
<button class="add_field_button">Add More Fields</button>
<!-- <div><input type="text" name="mytext[]"></div>
<div><input type="text" name="mytext[]"></div>-->
</div>
</fieldset>
<fieldset>
<div class="input_fields_wrap1">
<button class="add_field_button1">Add More Fields</button>
<!-- <div><input type="text" name="mytext[]"></div>
<div><input type="text" name="mytext[]"></div>-->
</div>
</fieldset>
JavaScript
$(document).ready(function() {
var max_fields = Infinity; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap");
var wrapper1 = $(".input_fields_wrap1"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var add_button1 = $(".add_field_button1");
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper).append('<div><input type="text" name="mytextPrimero[]"/><input type="text" name="mytextSegundo[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
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><input type="text" name="mytextPrimeroA[]"/><input type="text" name="mytextSegundoA[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
$(wrapper1).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
});