Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
133
rated 0 times [  138] [ 5]  / answers: 1 / hits: 143731  / 15 Years ago, wed, october 14, 2009, 12:00:00

What's the proper way to get the position of an element on the page relative to the viewport (rather than the document). jQuery.offset function seemed promising:




Get the current coordinates of the first element, or set the
coordinates of every element, in the set of matched elements, relative
to the document.




But that's relative to the document. Is there an equivalent method that returns offsets relative to the viewport?


More From » jquery

 Answers
156

Look into the Dimensions plugin, specifically scrollTop()/scrollLeft(). Information can be found at http://api.jquery.com/scrollTop.


[#98512] Friday, October 9, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alyssiat

Total Points: 608
Total Questions: 102
Total Answers: 101

Location: Japan
Member since Sat, Jun 6, 2020
4 Years ago
;