title: Swiper slider add class to active slide when attribute in HTML is set
body: <p>I want to add class to navbar when active slide has got attribute set for example "navbar-dark". I tried with class but my function doesn't work perfect. It is when I changed slide the class was adding to the second slide not to first slide.</p>
  
  <pre><code>$(document).ready(function () {
      var mySwiper = new Swiper('.swiper-container', {
          direction: 'horizontal',
          loop: false,
          mousewheel: {
              invert: false,
          },
      });
      mySwiper.on('slideChange', function (realIndex) {
          if ($('.swiper-slide.swiper-slide-active').hasClass('dark')) {
              $('#navbar').addClass('darknav')
          } else {
              $('#navbar').removeClass('darknav');
          }
      });
  });
  </code></pre>