Get distance of element from top of the window which changes when user scrolls

Viewed 662

I need to find distance between top of the window to the element. I can calculate that distance using offsetTop, But in offsetTop it only gives element's distance from top of the window, What I want is to decrease the distance when user scrolls up. And increase the distance when user scrolls down. So how to achieve this?

1 Answers
Related