做移动端项目的时候经常会遇到这样一个问题:点击某个元素,会弹出一个窗口,但是下面的内容还能滑动,为了增加用户体验,通常会在窗口弹出的时候阻止下面内容滑动,窗口消失后再恢复滑动:
代码如下:
<div class="content">
<div class="tanchuang">
......
</div>
</div>
function stopScroll(event){
event.preventDefault();
};if($(".tanchuang").css("display")=="block"){ $(".tanchuang").on("touchmove",stopScroll);
}else{ $('.tanchuang').off("touchmove",stopScroll);};
转载于:https://www.cnblogs.com/chengkun101/p/4616490.html