Javascript 锚不';我不再工作了

Javascript 锚不';我不再工作了,javascript,jquery,html,css,fullpage.js,Javascript,Jquery,Html,Css,Fullpage.js,我是Javascript的初学者,我的网站有一些问题。。。 我正在使用fullPage.js脚本和另一个用于带有隐藏子菜单的垂直菜单的脚本。 我的导航菜单脚本无法与fullPage.js一起使用。看起来不错,但我的锚不起作用了 我可能在某个地方出错了,但我找不到在哪里 $(document).ready(function () { $.fn.fullpage({ verticalCentered: false, resize: true,

我是Javascript的初学者,我的网站有一些问题。。。 我正在使用fullPage.js脚本和另一个用于带有隐藏子菜单的垂直菜单的脚本。 我的导航菜单脚本无法与fullPage.js一起使用。看起来不错,但我的锚不起作用了

我可能在某个地方出错了,但我找不到在哪里

$(document).ready(function () {
    $.fn.fullpage({
        verticalCentered: false,
        resize: true,
        scrollingSpeed: 750,
        easing: 'easeInQuad',
        navigation: false,
        navigationPosition: 'left',
        navigationTooltips: ['firstSlide', 'secondSlide'],
        slidesNavigation: true,
        slidesNavPosition: 'bottom',
        loopBottom: false,
        loopTop: true,
        loopHorizontal: false,
        autoScrolling: true,
        scrollOverflow: false,
        css3: false,
        paddingTop: '3em',
        paddingBottom: '10px',
        normalScrollElements: '#element1, .element2',
        keyboardScrolling: true,
        touchSensitivity: 5,
        continuousVertical: false,
        animateAnchor: true,
        //events
        onLeave: function (index, direction) {},
        afterLoad: function (anchorLink, index) {},
        afterRender: function () {},
        afterSlideLoad: function (anchorLink, index, slideAnchor, slideIndex) {},
        onSlideLeave: function (anchorLink, index, slideIndex, direction) {}
    });
});
$(函数(){
var menu_ul=$('.menu>li>ul'),
菜单a=$('.menu>li>a');
菜单隐藏();
菜单a.单击(功能(e){
e、 预防默认值();
if(!$(this).hasClass('active')){
菜单a.removeClass(“活动”);
菜单过滤器(“:可见”).slideUp('slow');
$(this.addClass('active').next().stop(true,true).slideDown('slow');
}否则{
$(this.removeClass('active');
$(this.next().stop(true,true.slideUp('slow');
}
});
});

地球。家。摧毁。

  • 因为您正在锚定单击事件中使用event.preventDefault(),这将限制页面重定向。去掉那个,

    menu_a.click(function (e) {
        if (!$(this).hasClass('active')) {
            menu_a.removeClass('active');
            menu_ul.filter(':visible').slideUp('slow');
            $(this).addClass('active').next().stop(true, true).slideDown('slow');
        } else {
            $(this).removeClass('active');
            $(this).next().stop(true, true).slideUp('slow');
        }
    });
    

    问题是您没有在fullpage.js插件中使用锚。 您可能已经删除了该行

    您将需要以下内容:

    $.fn.fullpage({
        anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
        menu: '#myMenu'
    });
    
    您不应该使用您发布的初始化。这只是一个示例,显示了所有可能的选项(除了已删除的
    锚定
    幻灯片颜色

    仅使用您需要的选项,并考虑每个选项的默认值(详细说明)。
    如果你根本不打算使用
    填充
    这样的东西是没有意义的。

    缺少
    。这就是为什么保持代码缩进干净很重要的原因。与原始代码比较:。erf抱歉,我不知道复制/粘贴发生了什么:(谢谢你的回答!这对我不起作用,但我可能忘记了什么。非常感谢!!现在它工作得很好!谢谢你的精彩剧本,我保证我会在网站上给你一些学分和$$$。谢谢你,祝你过得愉快!xx