移动端禁止遮罩层以下屏幕滑动

var ruleTxt = $(".wanfan .rule .rule-txt");
var ruleTxtBottom = $(".wanfan .rule .rule-txt .rule-txt-bottom");
var flag = '';
$(".wanfan .rule .rule-btn").on('click',function(){
var h=window.screen.height;
ruleTxt.css({'width':'100%','left':'0px'});
ruleTxtBottom.css({'height':h/2});
$(".rule .rule-txt").animate({'bottom':'0px'});
flag = 1;

});
document.addEventListener('touchmove', function (event) {    //监听滚动事件
if(flag==1){                            //判断是遮罩显示时执行,禁止滚屏
event.preventDefault();                   //最关键的一句,禁止浏览器默认行为
}
});

$(".wanfan .rule .rule-txt-top span").click(function(){
$(".rule .rule-txt").animate({'bottom':'-100%'});
flag = 0;
});

发现连遮罩层都不能滑动了,只能用到选择器;

 

http://www.cnblogs.com/licf/p/4691556.html

posted @ 2016-09-08 12:31  春风得意之时  阅读(2381)  评论(0编辑  收藏  举报