I was trying to generate a new form group by clicking the button. But after that all I can't remove selected group, because click event doesn't work. here is fiddle example: https://jsfiddle.net/f4v25ert/
(function($) {
'use strict';
$(document).ready(function() {
$('.add').on('click', function(e) {
e.preventDefault();
$('.groups').append('\
<div class="form-group">\
<input type="text">\
<a href="#" id="remove-input">Remove</a>\
</div>\
');
});
$('#remove-input').on('click', '.form-group', function(e) {
e.preventDefault();
$(this).parent('.form-group').remove();
});
});
}(jQuery));