Javascript 为什么可以';t removeEventListener
Javascript 为什么可以';t removeEventListener,javascript,html,Javascript,Html,我想在mouseup事件触发时删除mouseover事件,但为什么不能revomeEventListener以及如何修复它,看起来这是我在javascript中的弱点。在fnDown中,您将事件侦听器设置为位于dragBox上,但随后您尝试将其从dragArea中删除。如果要将侦听器从中删除,则需要将其附加到dragArea。此函数按预期工作 Drag.prototype.fnDown = function (e) { this.diff.x = e.clientX -
我想在mouseup事件触发时删除mouseover事件,但为什么不能revomeEventListener以及如何修复它,看起来这是我在javascript中的弱点。在fnDown中,您将事件侦听器设置为位于dragBox上,但随后您尝试将其从dragArea中删除。如果要将侦听器从中删除,则需要将其附加到dragArea。此函数按预期工作
Drag.prototype.fnDown = function (e) {
this.diff.x = e.clientX - this.dragBox.offsetLeft
this.diff.y = e.clientY - this.dragBox.offsetTop
this.dragArea.addEventListener('mousemove', this.fnMove,false)
}
工作示例:
请在您的问题中包含实际代码,不要链接到代码,以提高获得高质量答案的机会。谢谢,我太粗心了,找不到它