(function ($) {
$(window).on("scroll", function () {
//Loop Sections
$(".sectionbox").each(function (i, d) {
//And Get Current One
var sec = $(this);
var el = $(this).find('span');
if (
$(this).position().top - 100 <= $(document).scrollTop() && $(this).position().top - 100 + $(this).outerHeight() > $(document).scrollTop()
) {
el.html('
在可视窗口内: '+i+'
');
sec.css({backgroundColor: '#ccc'});
}else{
el.html('
在可视窗口外: '+i+'
');
sec.css({backgroundColor: '#fafafa'});
}
});
});
})(jQuery);
