美文网首页
在某个有滚动条的div中滚动,禁用页面的总滚动条滚动

在某个有滚动条的div中滚动,禁用页面的总滚动条滚动

作者: IssunRadiance | 来源:发表于2023-05-09 16:10 被阅读0次
    1. 禁止滚动条滚动
    stop(){
      var mo = function(e) { e.preventDefault(); };
      document.body.style.overflow = 'hidden';
      document.addEventListener("touchmove",mo,false);
    }
    
    1. 恢复滚动条滚动
    move(){
      var mo=function(e) { e.preventDefault(); };
      document.body.style.overflow = '';
      document.removeEventListener("touchmove",mo,false);
    },
    
    1. 在div滚动时调用stop() , 在div停止滚动时调用move()

    相关文章

      网友评论

          本文标题:在某个有滚动条的div中滚动,禁用页面的总滚动条滚动

          本文链接:https://www.haomeiwen.com/subject/pxgrsdtx.html