troubleshooting Question

Event Listener Status of Dynamically Removed/Created Element

Avatar of 894359
894359Flag for United States of America asked on
JavaScript
2 Comments1 Solution77 ViewsLast Modified:
What happens to an event listener which was attached to an element that gets dynamically removed and then dynamically recreated?  If I have a form and an event listener is attached to an element by ID (e.g. ID="f1") and then that element is removed while the even listener is attached;, will the event listener automatically go away or error? Additionally what happens if the element reappears (is recreated dynamically) after the initial attachment? This is in regards to the sequence below.

1) event listener A is attached to element with ID= "f1"
2) element "f1" is dynamically removed while event listener is attached
3) element "f1" is dynamically recreated

Thanks!
ASKER CERTIFIED SOLUTION
Francisco Igor
Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros