views:

68

answers:

1

I am basically trying to trigger a function if the footer is inside the viewport.

How can I check whether the footer is currently visible in the viewport?

I assume I will have to put it into the $(window).scroll() event so that the listener becomes true once the footer becomes visible but what the function should be I just can't figure out.

Any help would be much appreciated.

Thanks for reading,

Jannis

+1  A: 

Check if the top of the footer element is greater than the window height. Something like

$("#yourfooterid").position().top > $(window).height()
rahul
Hooking this check to `onload` (is it visible initially) and `onscroll` (is it visible after scrolling) event handlers should do the trick.
nikc