How do I detect if a user scrolls downwards with jQuery? I want a fixed div to show only when the browser is within 300px of the top. When the user scrolls down past the 300px mark, it should disappear. When the user scrolls back to the top, it should hide. How do I do this?
Share
Attach a scroll listener to the window:
http://docs.jquery.com/Events/scroll
Then check the scrollTop of window:
http://docs.jquery.com/CSS
When scrollTop is less than 300, show() the div, otherwise hide() it.