点击滚动指定高度 屏幕滚动事件

 $(".fix_nav span").click(function(){ //点击事件触发
                        
            $(this).addClass("cur").siblings().removeClass("cur");
            var Index = $(this).index()+1;
            
            var top = $("#fix_"+Index).offset().top; //获取某个元素距顶部的距离
           $("body,html").animate({scrollTop:(top-60)+"px"},500);//页面滚动到指定高度 
                                    })
                   
  $(window).scroll(function(){//窗口滚动事件触发
    var ws=$(window).scrollTop()//获取当前滚动高度
    if(ws>t){
    $(".fix_nav").addClass("isfix")    
        
    }else{
    $(".fix_nav").removeClass("isfix")    
        
        }
        })                                

 

posted @ 2017-01-07 14:57  MasterC  阅读(2098)  评论(0编辑  收藏  举报