【发布时间】:2015-09-16 13:44:25
【问题描述】:
我有以下问题:
setTimeout(function() {
myElement.bind("DOMSubtreeModified", function() {
if (something == true) {
console.log("Keep outputting this message");
} else {
console.log("Unbind event");
myElement.unbind("DOMSubtreeModified");
}
});
}, 3600);
由于某种原因,取消绑定不起作用,它会在 myElement 更改后不断重新启动关联函数。
我确实在控制台中反复看到一次“取消绑定事件”消息something != true
【问题讨论】:
-
我有trouble reproducing this。你确定它没有被多次绑定吗?
标签: javascript jquery events bind unbind