I'd just like to hide an element on my page, after N number of pixels have been scrolled.
$(window).scroll(function(){
if($(document).scrollTop() > 200){
$('.fixedelement').css({'display': 'none'});
}
});
I thought this might work, and after 200px of scrolling the .fixedelement would vanish. Alas, it doesn't work. Any thoughts?
Try this.
$(window).scroll(function(){
if($(document).scrollTop() > 200){//Here 200 may be not be exactly 200px
$('.fixedelement').hide();
}
});
It seems to work fine here: http://jsfiddle.net/maniator/yDVXY/
$(window).scroll(function() {
if ($(this).scrollTop() > 200) { //use `this`, not `document`
$('.fixedelement').css({
'display': 'none'
});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With