【发布时间】:2014-07-02 14:01:05
【问题描述】:
我有一个代码,其中我使用 jquery 的 .on 函数将多个事件处理程序附加到单个选择器
$(document).on({
mouseenter: function() {
console.log("handle enter");
},
mouseleave: function() {
console.log("handle leave");
},
click: function(){
console.log("clicked");
}
},'.handle');
现在我想删除所有这些事件处理程序。我知道这可以通过以下方式使用 .off 来实现
$(document).off("mouseenter",".handle");
$(document).off("mouseleave",".handle");
$(document).off("click",".handle");
但我担心的是我只想使用 .off 函数一次并实现上述目的。 我怎样才能做到这一点? 任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery event-handling live jquery-on