When the user scrolls down on my website, I’d like to detect when the very top header is out of view. Is this possible with jquery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As mentionaed by @RoryMcCrossan, you can calculate it yourself.
If you want a little more flexibillity, try this jQuery plugin:
http://www.appelsiini.net/projects/viewport
it’ll let you query the DOM based on whether the element is within the visible viewport.
For example:
will only return
divs that are currently visible.You can also query for elements that are not visible, based on where they are. Mainly:
Check out the link above for more info, and the download.
If you want to use this library to query for elements not currently shown,
regardless of where they are, then use this:
So, assuming your header has an ID of
header, you might use this: