开发者

Can you hide an html div with jQuery/Javascript when the page is scrolled to a certain number of pixels?

I hav开发者_JAVA百科e a div that is fixed position that I want hidden once the page is scrolled to a certain position. Is there any way to do this with jQuery/Javascript?


Yep, something like this should do the trick:

var max_scroll = 300;
$(document).scroll(function(){
  if($(this).scrollTop() >= max_scroll)
  {
      $('#my_div').fadeOut();
  }
});


$(document).scroll(function(){
    if($(document).scrollTop()>100){
        $("#myElement").hide();
    }
}

edit: Oop, I see someone already posted a working solution,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜