简体   繁体   English

原型:滚动页面800px时显示元素

[英]prototype: show a element when scroll page pased 800px

If user up, then hide the element. 如果用户使用起来,则隐藏该元素。 A div. 一格

i have something: 我有一些东西:

<script>

window.onscroll = function()
{

        if (document.documentElement.scrollTop > 900 || self.pageYOffset > 900) {
            $('#divId').css('display','block');
        } else if (document.documentElement.scrollTop < 900 || self.pageYOffset < 900) {
            $('#divId').css('display','none');
        }
}

</script>

But not work. 但是不行。

Something like this: 像这样:

$(window).scroll(function () {
    var $someDiv = $("#someDiv"),
        top = $(this).scrollTop();

    if (top > 200) {
        $someDiv.show();
    } else {
        $someDiv.hide();
    }
});​

See this Fiddle . 看到这个小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 justifiedGallery:屏幕 &lt;800px 时尝试更改图像路径 - justifiedGallery : Trying to change image path when screen <800px 我想移动左导航栏菜单 <div> 屏幕尺寸为800px时返回顶部 - I want to move my Left nav bar menu <div> to Top when the screen size is 800px 当浏览器的尺寸小于800px时如何隐藏div - How to hide div when browser resizes to less than 800px FB时间轴应用高度停留在800px - FB Timeline App Height Stuck at 800px 当我的窗口宽度小于800px时,如何将js滑块效果更改为淡入淡出? - how do i change the js slider effect to fade when my window width is less than 800px? 仅当最小宽度为800px时才执行Javascript - Executing Javascript only if min-width is 800px 如果窗口宽度大于800px时刷新站点,则jQuery click事件不起作用 - jQuery click event doesn't work if I refresh site when window width is bigger than 800px 如果窗口宽度在800px至799px之间,则执行JS函数 - Do JS function if window width between 800px and 799px JS-窗口的宽度从高于800px的像素数量减少到800px以下导致触发动作 - JS - Window's width being decreased below 800px from an amount of pixels that are higher than 800px causes an action to trigger Javascript-如果窗口宽度&lt;= 800px,则将活动链接移至导航顶部 - Javascript - Move active link to top of navigation if window-width <= 800px
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM