O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing Event Handlers in jQuery

$("div").off("keypress"): or $("div").off("click", "span",   function(e){     (event handler code here) }):

Removing an event handler in jQuery is extremely easy using the .off(events[,selector ][,handler(eventObject)]) method. This method has similar arguments to the .on() event handler. The arguments match so closely so that you can add multiple event handlers to elements. Using the arguments helps jQuery know which event matches the one you want to turn off.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required