移動端頁面滑動,取消滑動默認事件


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