Reputation: 5950
I am clear on the difference between .offset()
and .position()
in jquery (as outlined here), however I am confused about how these map to javascript functions. Based on this article it seems like .offsetTop
in javascript does the same thing as .position().top
in jquery. Is that true? If so, how do you get the behavior of .offset()
in javascript? If not, how do you get the behavior of .position()
?
Thanks!
Upvotes: 2
Views: 2447
Reputation: 5950
.position().top
in jQuery is equivalent to .offsetTop
in javascript.
Both articles referenced in the question are accurate.
Just remember that, as mentioned in the article on .offsetTop
, if you want the offset relative to the immediate parent element, you must set the position
attribute on that element.
I am still confused by this naming scheme, and I'm not sure how to get the behavior of jQuery .offset()
in javascript.
Upvotes: 3