js实现页面下拉后展示导航,以及点击导航自动滑动到相关页面

//监控,下拉750px后展示导航
$(window).scroll(function(){
    var $this = $(this);
    var targetTop = $(this).scrollTop();
    if(targetTop > 750){
        $("#fixed-menu").css('display','block');
    }else{
        $("#fixed-menu").css('display','none');
    }
});

//点击导航自动活动到页面
    $(".link1").click(function(){
        $('body,html').animate({'scrollTop':$(".fwjs").offset().top},800)
    });

    $(".link2").click(function(){
        $('body,html').animate({'scrollTop':$("#zzlc").offset().top},800)
    });

    $(".link3").click(function(){
        $('body,html').animate({'scrollTop':$(".clzb").offset().top},800)
    });

    $(".link4").click(function(){
        $('body,html').animate({'scrollTop':$("#xzfxq").offset().top},800)
    });

    $(".link5").click(function(){
        $('body,html').animate({'scrollTop':$("#gwtd").offset().top},800)
    });

    $(".link6").click(function(){
        $('body,html').animate({'scrollTop':$("#cjwt").offset().top},800)
    });
原文地址:https://www.cnblogs.com/cl94/p/10631873.html