0
votes
 var width = $slide.width() * 5;
 var animationSpeed = 150;
 $slide = $('.slide');

 function sliding() {

 $slider.animate({'margin-left': '-='+width}, animationSpeed);

 }

1-how can i make width = one slide width * 5 because it doesn't work

2- if i have 18 slides to slide in this slider and 5 slides appear on the div , can the div slide by 5 slides every time but after two times there will be 3 slides left how can i adjust the variable width to slide by the left of the slides only?

1

1 Answers

0
votes

You need to define $slide before getting its width:

// define $slide before getting its width
var $slide = $('.slide');
var width = $slide.width() * 5;
var animationSpeed = 150;

function sliding() {
    $slider.animate({'margin-left': '-='+width}, animationSpeed);
}

As for the second question, can you show your attempt to achieve so?