if( $("#homeLnk:visible").length )
alert( "This element is visible!" );
// if($("#homeLnk:hidden").length) is true if it's hidden with CSS
Tip: jQuery returns the element as hidden if it currently has either of these CSS properties:
"visibility:hidden" or "display:none" - Check them individually with the css() function: if( $("#homeLnk").css("display") == "none" )
alert( "This element is hidden with display:none!" );
Note: use $("#elm")[0].scrollHeight instead of $("#elm").height() to include padding when you retrieve the element's actual height. jQuery's "offset().top" does include any vertical margins.
var pageTopToDivBottom = $("#sstut").offset().top + $("#sstut")[0].scrollHeight;
var scrolledPlusViewable = $(window).scrollTop()+$(window).height();
// First check if the element is outside the viewable area:
if( $(window).scrollTop() > pageTopToDivBottom )
alert( "Element hidden (above viewable area)" );
else if( scrolledPlusViewable < $("#sstut").offset().top )
alert( "Element hidden (below viewable area)" );
else
alert( "Element visible! (within viewable area)" );
var isAboveTheFold = $("#sstut").offset().top < $(window).height();
That statement evaluates to false if the element in question is below the fold (before scrolling). Tip: to check if the element is partially or completely visible above the fold, add an integer (desired number of pixels) or its full height ( $("#sstut")[0].scrollHeight ) to the end.