I have a form that is dynamically added to the DOM and therefore I have to use event delegation.
I can not get this to fire and it looks to me like this event can only be attached to an input element
['change', 'blur'].forEach(event => {
document.addEventListener(event, e => {
if (e.target.closest('.dynamic-modal form input')) {
const $input = e.target.closest('.dynamic-modal form input')
console.log($input)
// never logs on change and blur
}
})
})
How can I go about solving this?