var width = $slide.width() * 5;
var animationSpeed = 150;
$slide = $('.slide');
function sliding() {
$slider.animate({'margin-left': '-='+width}, animationSpeed);
}
1 - 如何使宽度=一个幻灯片宽度* 5,因为它不起作用
2-如果我有18个幻灯片在这个滑块中滑动并且5个幻灯片出现在div上,div可以每次滑动5个幻灯片但是两次之后会有3个幻灯片,我如何调整可变宽度到仅滑动左侧滑动?
答案 0 :(得分:0)
您需要在获取宽度之前定义$slide
:
// 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);
}
关于第二个问题,你能表明你试图实现这个目标吗?