I\'m looking at using .off()
and .on()
to turn event handlers off and on in jQuery.
I can turn the all attached event hand
Yes, .off
basically removes the events so you will have redeclare them. you are better off having a global variable so your event handlers can check to see if it set to off or on and if off just return. And just change the variable to off or on, true or false or whatever suits you
var eventsOn = false;
function myFunc() {
if(!eventsOn) return;
//Code to run here.
}
//Somewhere else set your events and turn eventsOn to true
jQuery("#mydiv").on("click",myFunc);
eventsOn = true;