JavaScript jQuery Basics Understanding jQuery Events and DOM Traversal Using Events with Dynamically Added Elements

Amandeep Pasricha
Amandeep Pasricha
14,928 Points

I don't understand how this is possible if the button element does not exist in the DOM in the first place?

How is it possible to manipulate a button element if it does not exist in the first place in DOM? I kind of don't understand the concept shes teaching here.

1 Answer

Steven Parker
Steven Parker
173,876 Points

Delegated handlers do not manipulate anything that doesn't exist. However, when new items are created that trigger events, the delegated handler responds as the event "bubbles up" to the element it is listening on.