V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
VKMEPR

请教一个 jQuery 向上滚动问题

  •  
  •   VKMEPR · Jun 20, 2019 · 2627 views
    This topic created in 2509 days ago, the information mentioned may be changed or developed.

    问题描述:当导航菜单向下滚动超过指定元素高度时自动隐藏,向上则恢复显示,代码如下。

    请问能不能修改当向上滚动超过一定像素时才显示,比如 100px。

    $(function(){   
        var cubuk_seviye = $(document).scrollTop();
        var header_yuksekligi = $('.yapiskan').outerHeight();
     
        $(window).scroll(function() {
            var kaydirma_cubugu = $(document).scrollTop();
     
            if (kaydirma_cubugu > header_yuksekligi){$('.yapiskan').addClass('gizle');}
            else {$('.yapiskan').removeClass('gizle');}
     
            if (kaydirma_cubugu > cubuk_seviye){$('.yapiskan').removeClass('sabit');}
            else {$('.yapiskan').addClass('sabit');}               
     
            cubuk_seviye = $(document).scrollTop();   
         });
    });
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2411 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:46 · PVG 09:46 · LAX 18:46 · JFK 21:46
    ♥ Do have faith in what you're doing.