我正在尝试在我的页面上启用和禁用滚动
我有这个功能:
function scroll_toggle(key){
if (key) {
$(window).bind('scroll', function(){
$('body').on({
'mousewheel': function(e) {
console.log("binded");
$("html body").scrollTop(0);
if (e.target.id == 'el') return;
e.preventDefault();
e.stopPropagation();
}});
});
} else {
$(window).unbind('scroll');
$('body').on({
'mousewheel': function(e) {
console.log("unbinded");
return true;
}});
}
}
当我第一次使用true作为参数调用此函数时,鼠标滚轮不起作用,并且我有"绑定"在我的控制台中。
但是当我用虚假的方式调用该函数时,鼠标滚轮仍然无法工作,而且我已经绑定了#34; " unbinded"可替代地
我的代码有什么问题?
感谢您的时间