# Error while deleting table row from screen using event delegation

**URL:** <https://forum.freecodecamp.org/t/error-while-deleting-table-row-from-screen-using-event-delegation/412699>\
**Category:** General\
**Created:** [July 30, 2020, 7:17pm UTC](https://forum.freecodecamp.org/t/error-while-deleting-table-row-from-screen-using-event-delegation/412699 "2020-07-30T19:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsave](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@gsave](https://forum.freecodecamp.org/u/gsave)\
**Post date:** [July 30, 2020, 7:17pm UTC](https://forum.freecodecamp.org/t/error-while-deleting-table-row-from-screen-using-event-delegation/412699/1 "2020-07-30T19:17:01Z")

</div>

hi this is my code [https://codepen.io/anikettiwari/pen/gOPyYzj?editors=1010](https://codepen.io/anikettiwari/pen/gOPyYzj?editors=1010), in it when  
i’m clicking on dustbin icon sometimes my table row is deleting but sometimes an error is  
popping up in console pic is attached

 ![2020-07-31 00_40_43-Greenshot](https://global.discourse-cdn.com/freecodecamp/original/3X/b/6/b6e95ab7a240e7eccbbef7cbcba9ca054af39783.png)  
like in the above picture my rows are deleted but I am still getting this error.  
Also due to this my experience with is not smooth sometimes it deletes the row while sometimes it does not.  
how can i solve it and what is my mistake

i thing ` itemId = event.target.parentNode.parentNode.parentNode.parentNode.id;` is creating some problem, as sometimes it is returning id of the desired row then deletion is occurring while sometimes it showing that null value, but i’m not getting how?

on looking to the console log it is clear that  
event.target.id = delBtn  
event.target.parenetNode.id = del  
event.target.parenetNode.parenetNode.id = trainee–detail  
event.target.parenetNode.parenetNode.parenetNode.id = must be my desired row

but also in console i guess these extra `trainee--detail` coming due to pointer click is changing things and is not returning my desired row in one go how can i resolve it  
is there problem in my css dustbin icon positioning.

 ![2020-07-31 01_39_32-Greenshot](https://global.discourse-cdn.com/freecodecamp/original/3X/1/c/1cee1ace59699405919913467699d4aeb2c58bf2.png)  
help:  
in HTML , dustbin has id` id = "delBtn"` and parent id is` id="del"`  
in js , deleting code begins from `line 101`

---

<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/error-while-deleting-table-row-from-screen-using-event-delegation/412699/2 "2021-06-01T18:45:07Z")

</div>

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


