禁用iOS Overscroll,但允许正文滚动
我想禁用iOS应用程序在Web应用程序中的滚动,但仍然允许滚动。
$(document).on('touchmove', function(e) { e.preventDefault(); });
完全禁用滚动(如预期的那样)。
有没有办法做我想做的事情?
我有几乎相同的问题 。 这应该可以帮助你:
// Disable overscroll / viewport moving on everything but scrollable divs $('body').on('touchmove', function (e) { if (!$('.scrollable').has($(e.target)).length) e.preventDefault(); });
document.body.addEventListener('touchmove',function(e){ if(!$(e.target).hasClass("scrollable")) { e.preventDefault(); } });
试试这个我刚刚通过谷歌进入