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");
    }
});