how to detect a section is visible in jquery

JavaScript
// Checks CSS content for display:[none|block], ignores visibility:[true|false]
$(element).is(":visible");

// The same works with hidden
$(element).is(":hidden");.is(':visible')
//Selects all elements that are visible.

if($('#Div').is(':visible')){
	// add whatever code you want to run here.
}

$('#yourDiv:visible').callYourFunction();$.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;};
Source

Also in JavaScript: