jquery check if element visible on screen code example
Example 1: check if element is visible
.is(':visible')
if($('#Div').is(':visible')){
}
$('#yourDiv:visible').callYourFunction();
Example 2: how to detect a section is visible in jquery
$.fn.isInViewport = function() {var elementTop = $(this).offset().top;var elementBottom = elementTop + $(this).outerHeight();var viewportTop = $(window).scrollTop();var viewportBottom = viewportTop + $(window).height();return elementBottom > viewportTop && elementTop < viewportBottom;};