使用JavaScript事件代表团更改模糊事件
我有一个动态添加到DOM的表格,因此我必须使用事件委托。
我无法将其开火,在我看来,这个事件只能将其附加到输入元素上,
['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
}
})
})
该如何解决?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论