在手机浏览器中触发touchmove事件的同时默认会让滚动条滚动,有时候我们不喜欢这样,比如我们希望图片弹出层能固定住,不要让它随滚动条滚动,或者我们运用到touch事件的时候被滚动条干扰。这时我们可以这样做:
var box = document.querySelector(".searchM");
box.addEventListener('touchmove', function (event) {
event.preventDefault();
}, false);
在手机浏览器中触发touchmove事件的同时默认会让滚动条滚动,有时候我们不喜欢这样,比如我们希望图片弹出层能固定住,不要让它随滚动条滚动,或者我们运用到touch事件的时候被滚动条干扰。这时我们可以这样做:
var box = document.querySelector(".searchM");
box.addEventListener('touchmove', function (event) {
event.preventDefault();
}, false);
转载于:https://www.cnblogs.com/yayadoudou/archive/2012/07/22/2603536.html