I would like to add a class when the user scrolls to the top of a specific element.
I currently have this code but as you can see this is determined by the pixels from the top of the page. i would like it to be when the page scrolls to the top of an element as i am using percentages and making the site responsive so the pixels from the top of the page will vary dependant on the screen size.
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 610) {
$("header").addClass("header-animate");
} else {
$("header").removeClass("header-animate");
}
});
Please let me know if you require any more details.
Thanks.