Check List check and exclude only existing items

1

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

    
asked by anonymous 15.02.2018 / 03:49

1 answer

1

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 .

    
15.02.2018 / 03:58