One listener on ul.list, and the teacher reads every note that climbs from a pupil’s desk: pick e.target, e.currentTarget or closest(), then see what happens…
Delegation = one listener for hundreds of items (and items that do not exist yet), less memory, and no listener left behind. React itself puts its listeners on the app root this way. But there are three traps: e.target can be an element too deep, a stopPropagation() on the way cuts it off, and some events do not bubble.
Events climb from the target to the root, so one listener up top can handle them all
event.currentTarget for the clicked element currentTarget = the element the listener sits on (ul); the clicked one = event.target, and that can be the deepest child. For delegation, use e.target.closest('.item').stopPropagation() on the way cuts the bubbling, so the delegated listener above never runs. Find that call, or listen in the capture phase ({ capture: true }) if the code is not yours.focus, blur, mouseenter, mouseleave do not bubble. Use focusin/focusout/mouseover/mouseout, or add the listener with { capture: true }.span, but closest('.item') climbs to the li and the handler still gets its id. Follow the steps with Replay.e.target, click the word again The handler gets the span, which has no data-id: pilih(undefined). That is the most common delegation bug.button, click a Hapus button The path breaks at the button: ul never hears it, the handler stays silent.