📌  相关文章
📜  javascript 删除所有事件侦听器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:41.037000             🧑  作者: Mango

代码示例1
That is not possible without intercepting addEventListener calls and keep track of the listeners or use a library that allows such features unfortunately. It would have been if the listeners collection was accessible but the feature wasn't implemented.

The closest thing you can do is to remove all listeners by cloning the element, which will not clone the listeners collection.

Note: This will also remove listeners on element's children.

var el = document.getElementById('el-id'),
    elClone = el.cloneNode(true);

el.parentNode.replaceChild(elClone, el);