jquery, adding and removing event handlers

addeventlistener, events, jquery

Solution

If you want to remove an event handler bound with `jQuery.on` then you probably want `jQuery.off`

http://api.jquery.com/off/

Problem

I have 2 buttons ``` $(".button1").on("click", function(event){ $(".button2").on("click", function(event){ ``` What I would like to do is start with button1 as clicked and have no event listener, when button2 is clicked the event listener is removed and the event listener for button 1 is activated. This is a fairly common technique is in actionscript 3 with the method removeEventListener() and would like to use a similar method or technique in jquery.

Original source

Related problems