我想在laravel bootstrap 3 app中动态添加更多输入字段。但是当我点击添加时,即使我的项目中有jquery等,也没有任何反应:
索引负责人:
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
页脚:
<script src="{{ asset('/css/bootstrap/js/bootstrap.min.js') }}"></script>
文件中的代码:
<div class="form-group">
<div class="input-group control-group after-add-more">
<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">
<div class="input-group-btn">
<button class="btn btn-success add-more" type="button">
Add
</button>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
//here first get the contents of the div with name class copy-fields and add it to after "after-add-more" div class.
$(".add-more").click(function(){
var html = $(".copy-fields").html();
$(".after-add-more").after(html);
});
//here it will remove the current value of the remove button which has been pressed
$("body").on("click",".remove",function(){
$(this).parents(".control-group").remove();
});
});
</script>