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)
    });

 

posted @ 2019-03-31 16:29  cl94  阅读(445)  评论(0编辑  收藏  举报