I need to detect when an element appears and bind an eventListener to it.
There are 2 forms on the webpage, when submitted the first one is deleted and the second one is created dynamically depending on the first form values.
I can only run code onDomReady, I use $(function(){...});
I have tried to check if input[data-name="check3"]
exists using setInterval()
and when found I bind the eventListener to it.
I also tried to bind the eventListener after the first firm submit using setTimeout()
.
Both of these solutions "worked", but I wonder if there is a cleaner way to do it.