$(window).on('scroll',function(){
});
How can I unbind this? I've tried .off, but that doesn't seem to work.
$(window).on('scroll',function(){
});
How can I unbind this? I've tried .off, but that doesn't seem to work.
I just tried it on this website, but I assigned the callback to a separate variable
var callback = function (data) {
console.log(data);
}
$(window).on('scroll', callback);
and then to unset it
$(window).off('scroll', callback)
Try doing it specifically for the handler.
scrollHandler = function() {
};
$(window).on('scroll', scrollHandler);
$(window).off('scroll', scrollHandler);