jquery scrolling


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. It only follows that elements with scrollbars in positions other than the top would have a scrollTop of > 0. If you have an element without scrollbars then one would expect that their scrollTop position IS 0 as they have nowhere to scroll to.
  2.  
  3. I'm not exactly sure what the problem is.
  4.  
  5. EDIT: Just in case that it is not explained properly in the jQuery docs:
  6.  
  7. scrollTop() => position of scrollbar for element (window/div/anything scrollable)
  8.  
  9. $("#element").offset().top => position of element relative to page
  10.  
  11. $("#element").offset().top - $(window).scrollTop() => position of element relative to scrolled area.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.