Search code examples
javascriptjquerysliderslideswiper.js

How to Swiper Slider Mouse Hover Pagination


var sliderThumbs = new Swiper('.slider .slider-thumbs', {
            slidesPerView: 'auto',
            });
          var slidercontent = new Swiper('.slider .slider-content', {
            disableOnInteraction: false,
            thumbs: {
              swiper: sliderThumbs,
            },
          });

slide change to thumbs hover

not working the following code

$('.swiper-slide.thumb-slide').hover(function() {
      $( this ).trigger( "click" );
   });   

i do sorry for my bad english


Solution

  • $( this ).trigger( "click" ) won't work because the thumbnail slides don't actually have click events bound to them. Instead, you can call the slideTo() method and use the thumbnail's index, like so:

    $('.swiper-slide').on('mouseover', function() {
        slidercontent.slideTo($(this).index());
    })
    

    See the following: