Try using a class instead of the id #inputs
. Ids are only meant to exist one time in the page. Jquery uses document.getElementById()
to retrieve the dom element which will return the first element containing that id. You are allowed to use the same class name multiple times. if you added the class inputs
to the divs and used the selector .inputs
you should get the desired result.
You can change your jquery to append to the correct div as follows (it looks like the add button is always right before the div you are adding to):
$("input[name='add']").click(function( e ){
$(this).next().append( input );
});
This way, you wont even need a class to reference. It will add the input to the div after the add button.