How to detect scrolling with jQuery

Comments 0

Beware This post is more than 3 years old, it may be outdated or incorrect! Please check elsewhere for accurate information!

I often find tutorials on this topic that are either false or assume that you want to detect the whole page scrolling. Usually that's not the case and you only want to detect a div's scroll position.

Create a div with overflow-x: auto; and a fixed height (not height: auto;). Now put this code in your $(document).ready() segment and it should work.

Note: Every time you update the div's contents you must run this code again, it doesn't work with $(element).on('scroll').


Comments (0)

Please be civil when commenting. Think before writing, don't spam, self promote, bully, harass or harm anyone. Please read the Comment Policy before posting. Comments are moderated.

There are no comments.
Be the first to contribute!

Scroll to top