# Help With To Do List Delete Functionality

**URL:** <https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284>\
**Category:** General\
**Created:** [July 23, 2020, 3:37am UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284 "2020-07-23T03:37:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mish](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mish](https://forum.freecodecamp.org/u/mish)\
**Post date:** [July 23, 2020, 3:37am UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/1 "2020-07-23T03:37:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Advitya-sharma](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/advitya-sharma/32/151816_2.png) [@Advitya-sharma](https://forum.freecodecamp.org/u/Advitya-sharma)\
**Post date:** [July 23, 2020, 3:51am UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/2 "2020-07-23T03:51:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mish](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mish](https://forum.freecodecamp.org/u/mish)\
**Post date:** [July 23, 2020, 9:13pm UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/3 "2020-07-23T21:13:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Advitya-sharma](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/advitya-sharma/32/151816_2.png) [@Advitya-sharma](https://forum.freecodecamp.org/u/Advitya-sharma)\
**Post date:** [July 24, 2020, 1:26am UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/4 "2020-07-24T01:26:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mish](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mish](https://forum.freecodecamp.org/u/mish)\
**Post date:** [July 25, 2020, 1:38am UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/5 "2020-07-25T01:38:05Z")

</div>

Thanks for the help I was able to figure out how to add an id to each todo and have the array splice. 👍

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:45pm UTC](https://forum.freecodecamp.org/t/help-with-to-do-list-delete-functionality/411284/6 "2021-06-01T18:45:29Z")

</div>

Closed on June 1, 2021, 6:45pm UTC


