是否可以从具有多个处理程序的事件中删除一个特定的事件处理程序? [英] Is it possible to remove one specific event handler from an event with multiple handlers?
本文介绍了是否可以从具有多个处理程序的事件中删除一个特定的事件处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
As i searched for the solution of a problem i have right now, i found this thread: jQuery: more than one handler for same event. Now i wonder if it is possible to remove just a single one of these handlers?
推荐答案
如果您不使用匿名回调,则有可能:
It is possible, if you don't use anonymous callbacks:
var $elt = $(...);
function clickHandler1(event){...}
function clickHandler2(event){...}
// bind both
$elt.click(clickHandler1);
$elt.click(clickHandler2);
// unbind just the first
$elt.unbind('click', clickHandler1);
另请参阅: .unbind()
文档.
See also: .unbind()
docs.
这篇关于是否可以从具有多个处理程序的事件中删除一个特定的事件处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文