If I dynamically create an element through the click of a button, for example, a video element, is there some way for me to attach some event listener that is fired right after the DOM object is created in jquery and javascript?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is hacky solution that assumes the first handler doesn’t
.stopImmediatePropagation():The idea is that the other button click handler created the elements, and then your handler fires after which attaches your handlers on the created video element. Modify selectors and code.
It’s still less hacky than polling the dom for changes though.