12

I'm looking for a method to know if a object (as a Div, a img, etc.) is displayed and visible by the user at the window in JavaScript / jQuery.

When I say "is displayed and visible", that's when the user don't scroll the page enough to let's the object visible (If you know what I mean). But if the user scroll the page and the div is no longer visible (is out the window) the function what I'm looking for should know that.

4
  • check for :visible and :hidden Commented May 20, 2013 at 16:12
  • To tell if its in the current viewport, see this question: stackoverflow.com/questions/123999/… Commented May 20, 2013 at 16:14
  • 10
    meta.stackexchange.com/q/181040/34397 Commented May 20, 2013 at 16:18
  • What if the element is covered by another element? Commented May 20, 2013 at 16:19

1 Answer 1

12

You should use Viewport selectors for jQuery to check if the element is currently visible in the actual viewport.

Here's a demo to show you what I mean.

Sign up to request clarification or add additional context in comments.

1 Comment

Link no longer works... :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.