I'm loading elements via ajax. Some of them are only visible if you scroll down the page.
Is there any way I can know if an element is now in the visible part of the page?
EDIT: freakytard solution was right, but I modified it a bit to also check if element is wholly visible
function isScrolledIntoView(elem)
{
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
&& (elemBottom <= docViewBottom) && (elemTop >= docViewTop) );
}