如果我添加了事件处理程序...
$('button#test').click(function(){
// some actions
});
<button id="test">click me</button>
..然后我删除这个按钮元素,事件处理程序仍然在浏览器内存中,还是会消失?
我想知道我可以添加和删除绑定(bind)处理程序的元素多少次,这会占用大量内存吗?
最佳答案
只要您使用 jQuery 删除元素,您就可以确保处理程序也将被分离,而与您的代码运行所在的浏览器无关。
"In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed. "
关于javascript - JavaScript 事件处理程序在删除后是否会从浏览器内存中删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26126494/