javascript - 手机导航栏拉不出来?

标签 javascript jquery html css

我正在尝试创建移动导航菜单,但由于某些奇怪的原因,代码无法运行。我觉得这是 css 的问题,但我不确定。我创建了一个 JS Fiddle玩它。我希望在您单击小按钮时打开菜单。 JavaScript 不能读取请求...

Java 脚本

jQuery(document).ready(function () {
jQuery("#hamburger").click(function () {

    jQuery('#content').css('min-height', jQuery(window).height());

    jQuery('nav').css('opacity', 1);
    var contentWidth = jQuery('#content').width();
    jQuery('#content').css('width', contentWidth);
    jQuery('#contentLayer').css('display', 'block');
    jQuery('#container').bind('touchmove', function (e) {
        e.preventDefault();
    });
    jQuery("#container").animate({"marginLeft": ["70%", 'easeOutExpo']}, {
        duration: 700
    });
});
jQuery("#contentLayer").click(function () {
    jQuery('#container').unbind('touchmove');
    jQuery("#container").animate({"marginLeft": ["-1", 'easeOutExpo']}, {
        duration: 700,
        complete: function () {
            jQuery('#content').css('width', 'auto');
            jQuery('#contentLayer').css('display', 'none');
            jQuery('nav').css('opacity', 0);
            jQuery('#content').css('min-height', 'auto');
        }
    });
});
});

最佳答案

您的 jfiddle 中似乎没有加载 jquery。当我加载 jQuery 时,它对我有用。

点击 Javascript,然后点击“FRAMEWORKS & EXTENSIONS”并至少添加 jQuery 1.12。

关于javascript - 手机导航栏拉不出来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37638171/

相关文章:

JavaScript 最大表格大小

javascript - HTML offsetLeft 延迟更改

javascript - 如何将代码放入函数中

javascript - 如何使用jquery计算高度

javascript - 使用 AJAX 将基于 JSON 的远程数据导入 Select2

jquery - jquery ui 对话框是否支持从另一个对话框(并在其上)启动一个对话框

html - 我怎样才能更改代码以像图片中那样使用 HTML、CSS 平衡圆圈位置?

javascript - 使用 bootstrap-validate.js 将输入值设置在 1 到 10 之间的正则表达式

jquery - IOS HTML5 应用程序中的 iScroll4 js - 滚动到最上面的问题

javascript - 单击其他元素时重置功能