jQuery bind/unbind 'scroll' event on $(window)

后端 未结 6 786
梦谈多话
梦谈多话 2020-12-08 13:30

I have this function:

function block_scroll(key){
    if (key) {
        $(window).bind(\"scroll\", function(){
            $(\'html, body\').animate({scrol         


        
6条回答
  •  自闭症患者
    2020-12-08 13:52

    Note that the answers that suggest using unbind() are now out of date as that method has been deprecated and will be removed in future versions of jQuery.

    As of jQuery 3.0, .unbind() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

    Instead, you should now use off():

    $(window).off('scroll');
    

提交回复
热议问题