Navigation menu animation with javascript change div class doesn’t work on archive page

Question

I have a big problem, namely that an animation on my navigation bar that is working on my static frontpage, doesn’t work on archive page.

It’s a simple script, if scroll from top more than 20px, it adds a classname to my nav, which triggers a CSS animation.

    // NAVBAR ANIM SCROLL //
jQuery(function () {
  var navscroll = jQuery('.nav');
  jQuery(window).scroll(function () {
    var scroll = jQuery(window).scrollTop();

    if (scroll >= 20) {
      navscroll.addClass('scrolled');
    } else {
      navscroll.removeClass('scrolled');
    }
  });
});
// NAVBAR ANIM SCROLL END //

Console doesn’t give any error, and when I look into console, upon scrolling, the nav’s class simply doesn’t change.

Could someone help me here?
Thank you very much

0
Larry Sky 3 months 0 Answers 8 views 0

Leave an answer