-3

I'm trying to see which span element is visible on the screen or the closest to it upwards, I'm not exactly sure how to achieve this. The page will be scroll able and the spans will be visible. Is there a selector for visible on the screen?

user16217248
  • 3,119
  • 19
  • 19
  • 37
Crossman
  • 278
  • 5
  • 18
  • "Visible on the screen" meaning visible within the viewport or just visible anywhere on the web page? – Stian May 02 '13 at 12:48
  • @ChristianVarga but what I want is for it to be general. so that it could apply for any span element on the screen – Crossman May 02 '13 at 12:48
  • @Stian in the viewpoint. – Crossman May 02 '13 at 12:50
  • @Crossman that function requires minimal modifications to check all spans (hint: [.each()](http://api.jquery.com/jQuery.each/)). Give it a try before condemning it because it's not the _exact_ solution to your problem. We're here to help you code, not to write all your code for free :) – Christian May 02 '13 at 12:51

1 Answers1

0

Guess, you should compare window.scrollTop() and your element scrollTop values.
P.S. Do not not forget to include element height.

user16217248
  • 3,119
  • 19
  • 19
  • 37
Dmitry Volokh
  • 1,630
  • 16
  • 28