Click an item in your own list: Bu Guru’s board writes closest()’s ladder from e.target up to <html> and matches() on every rung. Where does closest() stop…
One listener on the container covers every button, including ones added later. But clicks almost always land on a child of the button (an icon, a span), so without closest() your handler misses.
closest() climbs until it matches, and does not stop at the listener
e.target directly without closest A click can land on a child of the button (svg, span). e.target.closest(".btn") climbs to the button. Do not assume target = the button.closest() return null. Always if (!hit) return before using the result.closest() filters by selector and can jump many levels (itself included); parentElement goes up one with no filter. And closest() can leave the container, so check container.contains(hit).e.target Not the button but the svg or path inside it. matches() is false too..card, click a Hapus button closest() jumps several levels, parentElement only one..card, click an empty gap in the list closest() leaves the list and finds the layout panel.