learningtech
learningtech

Reputation: 33685

find position of html element relative to visible browser area

I have a very long web page, so user needs to scroll to see the whole thing.

Half way down the page, I have an image element <img> . When this element is in the viewable area of the browser, I want to be able to determine the distance between the top of the element and the bottom of the search bar in my browser.

I have jquery installed, so I can leverage it's capabilities.

Is there an easy way to achieve what I'm looking for?

Thanks

Upvotes: 1

Views: 1968

Answers (1)

Paul S.
Paul S.

Reputation: 66334

You need .offset() and .scrollTop() then subtract.

Upvotes: 2

Related Questions