Several of the same sliders on the page?

  • 0
    There is a slider:
    let sliderCards;
       let mobSliderCards = document.querySelector('.card-row');
    
       function mobileSliderCards() {
          if ($('.card-row').length > 0) {
             if (window.innerWidth <= 660 && mobSliderCards.dataset.mobile == 'false') {
                sliderCards = new Swiper(mobSliderCards, {
                   slidesPerView: 'auto',
                   spaceBetween: 8,
                   loop: true,
                   watchSlidesVisibility: true,
                });
                mobSliderCards.dataset.mobile = 'true';
             }
    
             if (window.innerWidth > 660) {
                mobSliderCards.dataset.mobile = 'false';
                if (mobSliderCards.classList.contains('swiper-container-initialized')) {
                   sliderCards.destroy();
                }
             }
          }
       }
    
       mobileSliderCards();
    
       window.addEventListener('resize', () => {
          mobileSliderCards();
       });

    how to duplicate it on the page?
    JavaScript Aaron Russo, Feb 22, 2019

  • 1 Answers
  • 0
    mobileSliderCards2?
    Isla Church

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!