JavaScript · Middle · Question 71 of 75
What does event.target.closest("[data-id]") return?
- ✓Correct answer: The nearest ancestor (or the element itself) matching the selector, or
null - 2All descendants with
data-id - 3The next sibling with
data-id
Explanation
In delegated handlers the click often lands on a nested <span> or icon; closest finds the item element reliably.