Reputation: 25711
I need to get a position of an element on a page from the top of the element (div) to the current position of the top of the window. I DO NOT want the position relative to the top of the page (seems offset and position are doing this?)
Upvotes: 1
Views: 1787
Reputation: 12683
Try:
var top= $('#element').offset().top+ $(document).scrollTop();
Upvotes: 1
Reputation: 972
use $(element).offset().top
:
$(".element").offset().top;
and apply it to your page... Good luck
Upvotes: 0
Reputation: 11382
get the offset of the parent element, then get the offset of the child element, then substract one from the other - boom you got the information you were looking for.
Upvotes: 3