如果我将事件绑定(bind)到表中包含的多个元素。如果我通过构建新字符串并分配它来重新生成此表的 innerHTML
,事件是否仍然绑定(bind)?我必须重新绑定(bind)它们吗?
如果我手动修改 innerHTML
,jQuery.delegate
也能工作吗?
最佳答案
If i regenerate this table's innerHTML buy building a new string and assigning it, are the event still bound?
没有。
Do i have to rebind them all ?
是的。
Does jQuery.delegate also work if i modify the innerHTML manually ?
如果您要修改调用 .delegate()
的元素的 innerHTML
,则不行。如果您要修改其子级之一的innerHTML
,是的。
关于javascript - 事件绑定(bind)和修改innerHTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18175418/