Interview practice question
Click handlers don't work on newly added elements
Frontend Engineering · Async JavaScript and the Browser · Beginner
You attach click handlers to list items when the page loads, but items added later don't respond. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Handlers only attached to existing elements.
- Use event delegation on parent.
- event.target.closest() to find item.
- Or attach when creating.
- Delegation simpler for dynamic lists.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.