Why do we need parentNode of ul
Just cannot figure out why does Guil needed to select UL as such
let li = event.target.parentNode; let ul = li.parentNode;
whereas UL parentNode is listDiv, why not use use
let li = event.target.parentNode; let ul = event.target ul.remove(li)
This is my thinking or am I missing something?
Steven Parker170,403 Points
The "event.target" is the child of the list item, not the parent. It's the button that was clicked.
So to get the list itself, which is the parent of the list item, the "parentNode" property of the list item is used.
Debra Kellington2,978 Points
Thank you. This conversation helped me to understand it better. I, too, was confused as to the need for the parentNode of the button. The list item is actually the parent.