I want to dynamically add more input fields in my laravel bootstrap 3 app. But when I click add then nothing happens even if I have jquery etc in my project:
head of index:
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
footer:
<script src="{{ asset('/css/bootstrap/js/bootstrap.min.js') }}"></script>
Code in file:
<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>