JavaScript · Middle · Question 71 of 75

What does event.target.closest("[data-id]") return?

Explanation

In delegated handlers the click often lands on a nested <span> or icon; closest finds the item element reliably.

Further reading

Problem with a question

JavaScript · Middle · question 71

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz