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,
精彩评论