1
I need to disable a function in jquery, for example, when I click on a div, a function that I set will no longer run, just when I click on another div it will work again. The function is loaded when the site is loaded.
I need when I click on a div this function no longer works, just when I click on another div it comes back.
function executar_whell() {
function debounce(fn, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(context, args);
}, delay);
};
}
var scrollervateira = debounce(function (event) {
if (event.originalEvent.wheelDelta >= 0) {
$('.flexhome').flexslider('prev');
console.log('passa_slide');
return false;
} else {
$('.flexhome').flexslider('next');
console.log('volta_slide');
return false;
}
}, 250);
$(window).bind('mousewheel', scrollervateira);
}
;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
The executar_whell function will not be able to work when I click on a div ( div onclick=outright) and when I click on another div ( div onclick-work) it will work again.
If you put more code it is possible to help more, but for this feature you can use a flag, or remove Event Handler and put again with
.on()
and.off()
, or Bund/unbind. One aside: this function defectionfunction debounce(fn, delay) {
you don’t need to be insideexecutar_whell
. It’s kind of confusing being there.– Sergio