2012-08-22 40 views
2

我想知道是否可以刪除事件監聽器而不引用應該刪除的事件處理函數。removeEventListener不參考事件處理程序

Jquery的$().unbind('touchmove')將不起作用,因爲事件偵聽器是使用Javascript的addEventListener('touchmove', handlerFunction)添加的,而不是Jquery的bind函數。

removeEventListener(「touchmove」)似乎並沒有工作,這是用javascript函數規範

+0

http://stackoverflow.com/questions/5825493/removeeventlistener-is-not-working檢查最後的答案,也許幫助你 – Chris

+0

http://stackoverflow.com/questions/5296858/is-there-a-way-to-get-all-event-listener-bindings-in-javascript – David

+0

http://jsfiddle.net/qUtzL/4/這可能是你的問題? –

回答

-1

你應該總是將事件添加到特定的對象,以便以後可以訪問它們一致的,試試這個。

補充:

window.addEventHandler('touchmove', function); 

刪除:

window.removeEventListener('touchmove', function);