Sergey Smekodub Sergey Smekodub - 11 months ago 210
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,
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();

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.