Change stuff on scroll position

HTML
CSS
JAVASCRIPT
$(window).load(function() { var objectA = $('.a'); var objectB = $('.b'); var objectC = $('.c'); var objectAOffsetTop = objectA.offset().top; var objectBOffsetTop = objectB.offset().top; $(window).scroll(function() { var scroll = $(window).scrollTop(); if ((scroll >= objectAOffsetTop) && (scroll <= objectBOffsetTop)) { objectC.addClass("active"); } else { objectC.removeClass("active"); } }); });
Expand for more options Login