我正在尝试创建移动导航菜单,但由于某些奇怪的原因,代码无法运行。我觉得这是 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/