Skip to main content

Explain event delegation in jQuery.

Entry JQuery
Quick Answer Attach one listener to a stable parent, not to each dynamic child: $("ul").on("click", "li", function() { ... }). When a li is clicked, the event bubbles to ul, jQuery checks if the target matches "li", and fires the handler. This handles dynamically added li elements automatically - no need to re-bind after adding items.

Answer

Use .on(event, selector, handler) on parent to handle dynamic elements.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice