newbie
newbie

Reputation: 24635

How can I know if html element is on the screen?

I need know if element is on the sreen, or is it off the screen. How can I do that with jQuery ? For example if my element is out of screen it has attribute top: 3000px.

Upvotes: 0

Views: 1124

Answers (2)

tvgemert
tvgemert

Reputation: 1486

$(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document

If $(window).height(); is less than 3000px than your element is offscreen!

Upvotes: 3

Alex Rodrigues
Alex Rodrigues

Reputation: 2707

I don't know what are you trying to do but probabily there's a better way to do it.

Anyhow, you can see the position of the element and compare with the window boundaries.

Check this links to see how to do it:

Upvotes: 3

Related Questions