I’m a beginner coder. Does anybody know how to link thumbnail images to the swiper so that clicking a thumbnail moves the swiper-container to the corresponding slide? Thanks for your help!
Example: http://markdarren.com/F13/test.html
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="images/jacket2.png"></div>
<div class="swiper-slide"><img src="images/jacket3.png"></div>
<div class="swiper-slide"><img src="images/jacket4.png"></div>
<div class="swiper-slide"><img src="images/jacket5.png"></div>
</div>
</div>
<div class="thumb">
<div><a href="" title="onClick goto jacket 2"><img src="images/jacket2.png"></a></div>
<div><a href="" title="onClick goto jacket 3"><img src="images/jacket3.png"></a></div>
<div><a href="" title="onClick goto jacket 4"><img src="images/jacket4.png"></a></div>
<div><a href="" title="onClick goto jacket 5"><img src="images/jacket5.png"></a></div>
</div>
<script src="js/scroller/js/jquery-1.10.1.min.js"></script>
<script src="js/scroller/js/idangerous.swiper-2.0.min.js"></script>
<script>
var mySwiper = new Swiper('.swiper-container',{
pagination: '.pagination',
paginationClickable: true
})
</script>
Change everything in your script tag to:
$(document).ready(function() {
var mySwiper = new Swiper('.swiper-container',{
pagination: '.pagination',
paginationClickable: true
});
$(".thumb").on('click', 'div', function(){
mySwiper.slideTo($(this).index(), 500);
});
});
The bit I've added isn't tested, but should mean that on a click on one of the divs in your .thumbs bit (I'm ignoring your a tags) will swipe to the index of that div (e.g. is it div 1, div 2 etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With