JQ 禁用页面滚动条


<div style=" 100%;height:2000px;">
  <button style="margin-top: 200px;" onclick="show()">sssssss</button>
</div>
<div id="model" style="position: absolute;top:0;left:0;100%;height:100%;background:rgba(0,0,0,0.3)">
  <button onclick="hide()">eeeee</button>
</div>

  #model{
    display: none;
  }
  function show(){
   let model = document.getElementById("model")
   let top = $(document).scrollTop()
   model.style.top = top+"px"
   model.style.display = "block"
   scollchange(top)
  }
  function hide(){
    let model = document.getElementById("model")
    model.style.display = "none"
    $(document).unbind()
  }
  function scollchange(top){
    $(document).on('scroll.unable',function (e) {
        $(document).scrollTop(top);
    })
  }
原文地址:https://www.cnblogs.com/FormerWhite/p/15015345.html