Hi guys! I was wondering if someone could help with my delete functionality in my To Do List project. Right now I am able to delete an item but I can only delete the first item on the list and not the specific item I want to delete. For example, if I have items: 1,2, and 3, and I try to delete 3 it instead deletes 1. The same happens when I try to delete 2, 1 gets deleted instead. Any advice as to where I’m going wrong? Thanks.
I think its because you are deleting the list and first list item is getting deleted,
you can try giving unique id to every list item and get that to delete a particular todo
Thanks for the reply. I was able to use e.target.parentNode.remove() to remove a specific To Do. However, I still need to update my array to no longer include the deleted To Do. I’m not sure exactly what I should array .splice. (updated my jsfiddle)
You suggested adding an id to each ToDo, how would I go about that?
give id according to index starting from 1 or 0 , then when you remove a particular todo
example todo with id=3 and my id start from 0
remove that todo with from array which has id acc to index
Thanks for the help I was able to figure out how to add an id to each todo and have the array splice.