How to programmatically disable page scrolling with jQuery

后端 未结 23 2085
滥情空心
滥情空心 2020-11-22 08:09

Using jQuery, I would like to disable scrolling of the body:

My idea is to:

  1. Set body{ overflow: hidden;}
  2. Capture the current
23条回答
  •  醉话见心
    2020-11-22 08:33

    You can also use DOM to do so. Say you have a function you call like this:

    function disable_scroll() {
    document.body.style.overflow="hidden";
    }
    

    And that's all there is to it! Hope this helps in addition to all the other answers!

提交回复
热议问题