Add Remove Class on Vertical Scroll Using Jquery

In this tutorial we are going to teach you how we can add and remove the class on vertical scroll using jquery

$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    if (scroll >= 500) {
      $(".header").addClass("headerActive");
    } else {
      $(".header").removeClass("headerActive");
    }
});
Pitamber Singh
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.