我有以下几点:JQuery的 - 添加DIV父DIV
<div id="parentCalculation">
<div class="btn-group" role="group">
<button type="button" id="calculate" class="btn btn-default">Add</button>
</div>
Calculate below. Click on "Add to make another calculation
<div id="CalculateDiv">
<div class="calculation form-group well well-lg col-md-4">
<label for="cost">Enter Amount</label>
<input type="text" id="amount" class="form-control" placeholder="0.00">
<label for="type">Type</label>
<input type="text" id="type" class="form-control" placeholder="e.g. transfers">
<label for="comments">Comments</label>
<textarea class="form-control" id="cost-comments" placeholder="Enter comments"></textarea>
</div>
</div>
</div>
我想要做的就是calculation
追加父DIV CalculateDiv
以便有重复的值。
我使用下面的JQuery:
$(document).ready(function()
{
$("#calculate").click(function()
{
var x = $('.CalculateDiv');
alert(x);
$("#parentCalculation").append(x);
});
});
的问题是,它不添加到父DIV,我似乎无法找出原因。
见例如:Here
你不是创建一个新的元素,你只是移动它。使用'.clone()' –