jquery – 如何在移动菜单打开时禁用后台滚动?

我正在构建一个具有导航菜单的移动响应网站.
当我到达菜单底部时 – 如果我到达菜单底部继续滚动 – 它会在后台滚动页面.
我该如何禁用它?

到目前为止,这是我的jQuery代码

// When the document is loaded...
$(document).ready(function() {

    $('#mob-menu-btn').click(function(){
        $('.sports').slidetoggle("slow");
    })

    $('#sub-menu').click(function(){
        $('.sports2').slidetoggle("slow");
    })

});

这是我的CSS:

.list{
        width: 100%;
        overflow: hidden;
        overflow-y: auto;
        top: -10%;
        overflow: hidden;
        overflow-y: auto;
}


    .sports li{
        list-style-image:none;
        list-style-type: none;
        border-bottom: 2px solid #eeeeee;
        margin-bottom: 0px; 
        margin-left: 0px; 
        padding-top: 15px;
        padding-bottom: 15px;
        padding-left: 10px;
        width:100%;
        font-family: arial;
        text-decoration: none;
        overflow: hidden;
    }

解决方法

菜单打开时,将位置固定在主体上.关闭它时,删除属性.更好地使用添加/删除类.
if($('#mob-menu').is(':visible'))
 {
    $('body').addClass("fixedPosition");
 }
 else
 {
    $('body').removeClass("fixedPosition");
 }
.fixedPosition
 {
    position: fixed;
 }

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...