移动端页面滑动,取消滑动默认事件


1.js方法

$('body').on('touchmove',function(event){
        event.preventDefault && event.preventDefault();
        event.returnValue=false;
        event.stopPropagation && event.stopPropagation();
        return false;
    })
//或者在对应的事件添加取消默认事件
$('.scrollDiv').on('touchmove',function(event){
   event.preventDefault(); 
})

问题:超出页面的部分不能滑动显示出来

2.css方法 (可以解决js方法产生的问题)

//body使用绝对定位
body {
    position: fixed;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM