-2

Hi guys:)How can I see what of ten elements is visible in viewport?

Tovelo
  • 1
  • 1
  • 3
  • Please search a little before ask, and try yourself the codes – DaniP Jun 17 '16 at 15:37
  • http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom – DaniP Jun 17 '16 at 15:37
  • http://stackoverflow.com/questions/178325/checking-if-an-element-is-hidden – DaniP Jun 17 '16 at 15:37
  • I have changed my question,now it is different from the ones you have posted – Tovelo Jun 17 '16 at 17:21
  • How is this different ... also it is still off-topic to SO please include your relevant code here, an example an what you have tried – DaniP Jun 17 '16 at 17:23
  • I really don't understand downvotes logic in this forum...if I have posted this question is because I have not found answares!I don't know how to do so I have not written code,for this reason I am here asking you!The discussions you have posted haven't the resolution for the problem I have – Tovelo Jun 18 '16 at 07:26
  • The thing here is SO isn't a forum is a Q&A site read ... http://stackoverflow.com/help/how-to-ask ... and welcome to the community – DaniP Jun 20 '16 at 13:29

1 Answers1

0

One way of doing it would be based on whether the elements position (using offset position with respect to the document) see if that is within the view area (by getting the scrolltop position (top of screen) and the window height you can get the top and bottom (scrolltop + window height) of the view area.

So you can either check if the top of the element is greater than the scrolltop and less than the bottom of screen, or even check if its completely inside going along these lines.

Arathi Sreekumar
  • 2,454
  • 1
  • 15
  • 27
  • Thanks for the answare:):)But if I have to check what of 10 elements is visible on scroll?How could I do? – Tovelo Jun 17 '16 at 15:38
  • You'll have to figure all that out, thats too broad and leading on from the topic for me to answer. You can read up on the duplicate answer or look up individual steps on stackoverflow as you go along. – Arathi Sreekumar Jun 17 '16 at 15:40