Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 取消绑定鼠标滚轮事件并再次绑定它_Javascript_Jquery - Fatal编程技术网

Javascript 取消绑定鼠标滚轮事件并再次绑定它

Javascript 取消绑定鼠标滚轮事件并再次绑定它,javascript,jquery,Javascript,Jquery,我正在使用jquery-mousewheel.js插件,我想决定,如果用户向下滚动,那么内容应该淡出,用户应该看到下一部分。 在此事件期间,类发生更改,事件应停止,并且只有下一次向下滚动才会再次触发绑定/解除绑定。我已经尝试了下面的代码,但它不工作,任何建议是感激的 $('body').bind('mousewheel', function(event, delta) { if (delta> 0){ return false; } else{ if

我正在使用jquery-mousewheel.js插件,我想决定,如果用户向下滚动,那么内容应该淡出,用户应该看到下一部分。 在此事件期间,类发生更改,事件应停止,并且只有下一次向下滚动才会再次触发绑定/解除绑定。我已经尝试了下面的代码,但它不工作,任何建议是感激的

$('body').bind('mousewheel', function(event, delta) {
    if (delta> 0){
        return false;
    } else{
    if ($("#next-screen").hasClass("home")){
       // Hide home, show news
    $("#next-screen").removeClass();
    $("#next-screen").addClass("news");
    $( 'body' ).unbind( "mousewheel" );
} else
if ($("#next-screen").hasClass("news")){
    //Here should bind again
    //Hide news, show about
    $("#next-screen").removeClass();
    $("#next-screen").addClass("about");        
}
//etc.
}
});

如果你解除了事件的绑定,你需要在你想要添加它的时候重新绑定它。你在哪里这么做?可能是@Mark的复制品实际上这是我的问题:如何重新绑定它。我已经在我的代码中进行了注释,我希望重新绑定,但是由于它在函数中,我不知道如何使它工作。如果我只是尝试:$body.bind mouseweel;那不行。