I'm stuck on this.
I'm doing a dynamic form in jQuery and I want to add a remove button which is dynamically created when I click on a Add new tasks
.
So there is my JS script. First one is the Add new tasks button
:-
$("#bttn-add").click(function(){
$("#bttn-add-function").before(
'<div class="toadd panel panel-default panel-body">'+
'<div class="form-group func">'+
'<label>Función a desarrollar <sup style="color:red">*</sup></label>'+
'<input class="form-control" type="text" placeholder="Función a desarrollar" maxlength="200" required>'+
'</div>'+
'<div class="form-group tarea">'+
'<label>Tarea principal en esta función <sup style="color:red">*</sup></label>'+
'<textarea class="form-control" placeholder="Enumere las funciones de su puesto de trabajo comenzando por las más representativas, así como las tareas necesarias para el cumplimiento de las mismas" rows="3" required></textarea>'+
'</div>'+
'<div>'+
'<button class="button btn-danger" type="button"><span class="fa fa-minus"></span></button>'+
'</div>'+
'</div>'
);
});
And then, the snippet for adding a behavior to the Delete
button which doesn't work:-
$("button .btn-danger").click(function(){
console.log($(this).parent())
})
Note: it works with the "Add new Tasks" button but "Delete"