我的HTML是:克隆格
<div id="product">
<div class="clonedInput" id="input">
<div class="row">
<div class="col-md-6 col-md-offset-1">
{!! Form::label('product','Product: ') !!}
<select name="product" size="1">
@foreach($products as $p)
<option value="{{ $p->name }}">{{ $p->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-2 col-md-offset-1">
{!! Form::label('prodquant','Product Quantity: ') !!}
{!! Form::input('number','prodquant','1', ['class' => 'form-control', 'step' => 'any'])
!!}
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-1">
{!! Form::label('proddescription','Description: ') !!}
{!! Form::textarea('proddescription',null,['class' => 'form-control']) !!}
</div>
</div>
<div class="removebtn"></div>
</div>
我的jQuery是:
var rowNum = 0;
$(document).ready(function(){
rowNum++;
$(".cloneme").click(function(){
var nextHTML = $(".clonedInput").clone()/*.appendTo("#product")*/;
nextHTML.attr('id','input' + rowNum).appendTo('#product');
});
});
它工作在复制.clonedInput格罚款,但我需要.product,.prodquant和.proddescription的子类与#input一起增加。
如果任何人都可以指出我如何在那里得到一个删除按钮的正确方向,我会非常感激!
提示:考虑对“可复制”元素使用模板标签(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) – Seza