marko krstić

Collections

Archives

Add class to the element on scroll

$(window).scroll(function(){
    if ($(this).scrollTop() > 100) {
       $('.element').addClass('active');
    } else {
       $('.element').removeClass('active');
    }
});

Change element class or ID on lines 3 and 5 to trigger right elements and on line 2 100 is how many pixels to scroll until class is added.

Let's Connect

Feel free to reach out for collaborations or just a friendly hello 😀
mailme@markokrstic.com
linkedininstagramdribbblefacebook-official