I have a code in which I have attached multiple event-handlers to a single selector using .on function of jquery
$(document).on({
mouseenter: function() {
console.log("handle enter");
},
mouseleave: function() {
console.log("handle leave");
},
click: function(){
console.log("clicked");
}
},'.handle');
Now I want to remove all this event-handlers. I know this can be achieved using .off in the following way
$(document).off("mouseenter",".handle");
$(document).off("mouseleave",".handle");
$(document).off("click",".handle");
However my concern is I just want to use .off function only once and achieve the above. How can I do this? Any help will be appreciated.
You can just seperate the events by spaces, see the 2nd description of the .off function here: http://api.jquery.com/off
$(document).off("mouseenter mouseleave click",".handle");