Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jquery/javascript防止touchmove事件移动背景?_Javascript_Jquery_Ipad_Mobile_Touchmove - Fatal编程技术网

如何使用jquery/javascript防止touchmove事件移动背景?

如何使用jquery/javascript防止touchmove事件移动背景?,javascript,jquery,ipad,mobile,touchmove,Javascript,Jquery,Ipad,Mobile,Touchmove,目前我正在为ipad Safari开发一个网站 我曾经 addEventListener('touchmove', function(e) { e.preventDefault(); }, true); 以防止拖动内容时背景移动。问题是当我允许某些元素拖动时 addEventListener('touchmove', function(e) { //alert (e.target.id); if ( e.target.className != 'issues' &am

目前我正在为ipad Safari开发一个网站

我曾经

addEventListener('touchmove', function(e) { e.preventDefault(); }, true);
以防止拖动内容时背景移动。问题是当我允许某些元素拖动时

    addEventListener('touchmove', function(e) { 
    //alert (e.target.id);
    if ( e.target.className != 'issues' && e.target.id != 'dialog' && e.target.id != 'issuesBox') 
    e.preventDefault(); 
    return false;
    }, true);

当我拖动元素时,它也会拖动背景,如何解决这个问题?我注意到这个问题可能是由点击造成的,谢谢。

您是否试图阻止在某些元素上滚动?然后防止
touchstart
touchmove
事件的默认设置。这是苹果的

根据我的经验,在
touchstart
事件上防止默认设置就足够了,例如

$(document).on('touchstart', function (evt) {
    evt.preventDefault();
});