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

后端 未结 6 796
梦谈多话
梦谈多话 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:55

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

    Even though the documentation says it will remove all event handlers if called with no arguments, it is worth giving a try explicitly unbinding it.

    Update

    It worked if you used single quotes? That doesn't sound right - as far as I know, JavaScript treats single and double quotes the same (unlike some other languages like PHP and C).

提交回复
热议问题