jquery - Bottom Scroll Checked acts in reverse -
so i'm trying detect if page has scrolled way bottom, , found code:
$(window).scroll(function() { if($(window).scrolltop() + $(window).height() == $(document).height()) { alert("bottom!"); } });
and works... in complete reverse! instead of letting me know when i've scrolled way bottom, detects when i've scrolled @ top.
would tell me why it's doing on end?
this function adding how far down you've scrolled $(window).scrolltop()
height of viewport $(window).height()
. when greater or equal height of webpage $(document).height()
, triggers alert.
my guess webpage isn't higher viewport, alert message triggers @ top of page. see jsfiddle. function working fine (view console log) because content of page taller viewport.
Comments
Post a Comment