I have a check-list done in js, where the user types the task and it appears in the list. But I can only mark as "task completed" or "delete task" the existing tasks, that is, when I include a task I can not delete or mark it.
Follow codepen: link
I have a check-list done in js, where the user types the task and it appears in the list. But I can only mark as "task completed" or "delete task" the existing tasks, that is, when I include a task I can not delete or mark it.
Follow codepen: link
Delegation problem. Change event handlers :
$(document).on('click','.checked-task',function(){
$(this).parent().find('.name-task').toggleClass('name-task-toggle');
});
$(document).on('click','.remove-task',function(){
$(this).parent().hide('slow');
});
Dynamically added elements are not in the DOM. Soon the above syntax can listen for new elements.
There are already some answers with the same problem: answer 1 , answer 2 , answer 3 .