In a div that has overflow:scroll, how do I check what position the scroll is at?
Using JQuery.
How do I know if it's scr开发者_如何学Goolled to the middle? Top? Bottom?
You can use the element's scrollLeft
, scrollTop
, scrollWidth
and scrollHeight
properties to find out the status of the element's scrolling.
jQuery will allow you to get scrollTop
property like an attribute...
$('element').attr('scrollTop');
scrollTop gets or sets the number of pixels that the content of an element is scrolled upward
MDC Docs
精彩评论