我的任务是在点击添加按钮时添加上一个表单。
当我点击“添加”按钮时,它会在每个下方添加所有下拉菜单,如图所示。
删除一行(表示一行的所有5个下拉列表。)我将执行此功能。
问题是:
我们如何在每次点击添加按钮时添加或添加一行。
我的指点是: jQuery的:
$(document).ready(function () {
$(".glyphicon").click(function () {
$(this).parents('.form-group').remove();
});
$(".add").click(function () {
$("form").parent(".form-group").add();
});
});
$(document).ready(function () {
$(".glyphicon").click(function () {
$(this).parents('.form-group').remove();
});
$(".add").click(function () {
$("form").parent(".form-group").add();
});
});
HTML:
<div class="form-group">
<div class="col-sm-12" >
<div class="btn-group week">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">All days
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li class="week"><a href="#">Monday</a></li><li class="week"><a href="#">Tuesday</a></li>
<li class="week"><a href="#">Wednesday</a></li><li class="week"><a href="#">Thusday</a></li>
<li class="week"><a href="#">Friday</a></li><li class="week"><a href="#">Saturdayy</a></li>
<li class="week"><a href="#">Sunday</a></li>
</ul>
</div>
<div class="btn-group week">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Time
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li class="week"><a href="#">Monday-saturaday</a></li>
</ul>
</div>
<label for="exampleInputEmail1"> : </label>
<div class="btn-group week">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">.00
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="height: 10em;width:2em; overflow: auto;">
<li class=""><a href="#">.00</a></li><li class=""><a href="#">.01</a></li>
<li class=""><a href="#">.02</a></li><li class=""><a href="#">.03</a></li>
<li class=""><a href="#">.04</a></li><li class=""><a href="#">.05</a></li>
<li class=""><a href="#">.06</a></li><li class=""><a href="#">.07</a></li>
</ul>
</div>
<label for="exampleInputEmail1"> to </label>
<div class="btn-group week">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Time
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li class="week"><a href="#">Monday-saturaday</a></li>
</ul>
</div>
<label for="exampleInputEmail1"> : </label>
<div class="btn-group week">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">.00
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="height: 10em;width:2em; overflow: auto;">
<li class=""><a href="#">.00</a></li><li class=""><a href="#">.01</a></li>
<li class=""><a href="#">.02</a></li><li class=""><a href="#">.03</a></li>
<li class=""><a href="#">.04</a></li><li class=""><a href="#">.05</a></li>
<li class=""><a href="#">.06</a></li><li class=""><a href="#">.07</a></li>
</ul>
</div>
<span class="glyphicon glyphicon-remove"></span>
</div>
</div>
答案 0 :(得分:1)
答案 1 :(得分:0)
coading是:
$("#add").click(function(){
$(".abcd:last").clone().appendTo(".wrapper");
});
参考链接: