いくつかのフィールドがあり、さらにいくつかがjqueryによって生成されたフォームがあります。問題は、新しいものが既存のものと一致しないことです。CSSをいじってみましたが、うまくいきませんでした。これはまさにこの男の問題ですが、彼は応答を受け取りませんでした:
これは私のフォームです:
<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>
そして、これは私が追加のフィールドを生成するために使用しているJSです:
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>');
});
});
ただし、結果は次のようになります。
(スペースを削除してください。画像を投稿できません)