Section: Events
Event delegation
javascript
javascript
list.addEventListener("click", (event) => {
const item = event.target.closest("[data-id]");
if (!item) return;
console.log(item.dataset.id);
});Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Events