手机版浏览器禁止滚动条与释放实例

<script>  
function ask(){  
    $(".ask").click(function(){  
        $("body").css("overflow","hidden");  
        $(".popwind").show();  
        $('body').bind("touchmove",function(e){    
                    e.preventDefault();    
            });  
    });  
}  
ask();  
$(".pop_close").click(function(){  
    $("body").css("overflow","auto");  
    $(".popwind").hide();  
    $("body").unbind("touchmove");  
});  
</script>  

  

写页面事件的时候,有的时候需要用event.preventDefault取消原有的事件后进行重写,这个大家应该都知道。

那么怎么在取消默认事件后再恢复呢。

解绑我们自定义的事件就好了。

以Jquery为例

我们用$(“body”).bind(“touchmove”,function(event){event.preventDefault;//code});取消了body的拖动事件。

恢复这个拖动事件只要$(“body”).unbind(“touchmove”);

原文地址:https://www.cnblogs.com/xupeiyu/p/4791021.html