點擊滾動指定高度 屏幕滾動事件


 $(".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")    
        
        }
        })                                

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM