Sergey Smekodub Sergey Smekodub - 1 year ago 318
Javascript Question

myswiper.slideTo() is not a function

i have this error in console, but i dont understand why

var mySwiper = new Swiper('.swiper-container', {
speed: 400,
loop: true,
slidesPerView:1,
calculateHeight: true,
spaceBetween: 50,
watchActiveIndex: true,
prevButton: '.swiper-button-prev',
nextButton: '.swiper-button-next'
});

$('input[type=radio][name=radio]').change(function() {
var indx = $(this).val();
mySwiper.slideTo(indx,400,false);
});


screen shot of error

Answer Source

mySwiper is not defined in your change function.

I guess if you check the value of mySwiper in your change function, it will be null as it hasn't been set in the contect of your function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download