发生一定量的滚动时隐藏元素

Fue*_*ssi 5 jquery animation scroll

在滚动N个像素后,我只想在页面上隐藏一个元素.

$(window).scroll(function(){
  if($(document).scrollTop() > 200){
    $('.fixedelement').css({'display': 'none'});
  }
});
Run Code Online (Sandbox Code Playgroud)

我认为这可能会起作用,在滚动200px后,.fixedelement会消失.唉,它不起作用.有什么想法吗?

Nea*_*eal 8

这似乎工作正常:http://jsfiddle.net/maniator/yDVXY/

$(window).scroll(function() {
    if ($(this).scrollTop() > 200) { //use `this`, not `document`
        $('.fixedelement').css({
            'display': 'none'
        });
    }
});
Run Code Online (Sandbox Code Playgroud)