【问题标题】:Make scrollbar appear on vertical menu when page resized调整页面大小时使滚动条出现在垂直菜单上
【发布时间】:2014-05-22 20:10:46
【问题描述】:

在本应非常简单的事情上遇到了麻烦。基本上,我有右侧垂直菜单,当页面调整到某个点时,我的客户希望在其中包含一个滚动条。

    <div id="hamburger_menu_parent">
        <span id="toggle-menu"></span>         // User clicks this to open the hamburger menu
          <div class="mobile-navigation open"> // The "open" class is appended with 
                                               // jQuery when menu is clicked.
          <div id="navigation">            
            <ul style="margin-top: 25px;">
              <li>List item </li>
              <li>List item </li>
              <li>List item </li>
              <li>List item </li>
              <li>List item </li>
            </ul>

        </div>
    </div>
</div>

我拥有的 jQuery 就是这个(在另一个网站上搜索它,并且必须从他们的代码中找出哪些部分是相关的):

function ScrollMenuMobile(){
$('.mobile-navigation.open').css('height', $(window.height() + 'px'));
}

$(document).ready(ScrollMenuMobile);
$(document).resize(ScrollMenuMobile);

似乎无法让它工作。 css 属性从未在 .mobile-navigation.open 中输入,我在 Firebug 中收到错误:

ReferenceError: $ is not defined
$(document).ready(ScrollMenuMobile);

您可以点击汉堡菜单并在此处查看:

www.prometrika.com/newPMK

已经搜索了几个小时并尝试了所有方法。 Jsfiddles 很好地指出我做错了什么。

【问题讨论】:

    标签: jquery css navigation scrollable


    【解决方案1】:

    $('.mobile-navigation.open') 未定义,因为您的 div 有 2 个单独的类:mobile-navigationopen。它们不一样。

    尝试通过$('.mobile-navigation')选择它。

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 2012-05-20
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 2013-07-15
      • 2016-11-27
      • 1970-01-01
      相关资源
      最近更新 更多