I have a form that has some fields and then some more generated by jquery. The problem is the new ones do not align to the existing ones. I tried fiddling with CSS, but it didn’t work. This is exactly this guy’s problem, but he didn’t get a response:
This is my form:
<form id="recipe" name="recipe" action="create.php" method="post">
<h2>Ingredients</h2>
<div id="labels">
<label class="label" for="quantity">Quantity:</label>
<label class="label" for="unit">Unit:</label>
<label class="label" for="ingredient">Ingredient:</label>
</div>
<div id="inputs">
<div class="fields">
<input class="quantity" name="quantity[]" type="text" />
<input class="unit" name="unit[]" type="text" />
<input class="ingredient" name="ingredient[]" type="text" />
</div>
</div>
<div id="container">
<a id="add" href="#"><span>» Add ingredient.</span></a>
</div>
<div>
<h2>Directions</h2>
<textarea name="preparacion" rows="10" cols="51"></textarea>
</div>
<input type="submit" value="Guardar" />
<input type="reset" value="Limpiar" />
</form>
And this is the JS I’m using to generate the additional fields:
var count = 0;
$(function(){
$('a#add').click(function(){
count += 1;
$('#inputs').append('<div class="fields"><input class="quantity" name="quantity[]" type="text" /><input class="unit" name="unit[]" type="text" /><input class="ingredient" name="ingredient[]" type="text" /></div>');
});
});
However, the result is as follows:
(please remove the spaces, it won’t let me posts images)

The problem is that in the original row of input you have the inputs separated by a new line or a space character, when you add the new row you are appending all the code together and it renders one input closer to the previous one.
Simple solution, add a space after each input in the js code: