JavaScript JavaScript and the DOM Traversing the DOM Using parentNode to Traverse Up the DOM

need help on the parent.node.

line 12 in the video mark 4:15. now i understand that the parent element of the button is the <li> tag in this case. im confused what its actually doing.. so someone just clarify me about the part of the if condition code block.

1 Answer

Steven Parker
Steven Parker
201,292 Points

The event listener is attached to the div around the whole list, so the handler will run when you click anything inside it. The "if" makes sure the that click was on a button before doing anything else.