光滑滑块和幻灯片的数量

时间:2017-12-15 12:04:05

标签: javascript jquery slick.js

我已经找到了关于如何用当前/幻灯片总数(3/5)替换点的多个答案。但我还没有发现是否可以保留点,并在点的末尾添加当前/总数的幻灯片。

这可能吗?

1 个答案:

答案 0 :(得分:1)

添加参数dots: true将显示您的点数以及当前和总数。

示例:

HTML:

<div class="slideshow">
    <img src="http://lorempixel.com/500/250" />
    <img src="http://lorempixel.com/500/251" />
    <img src="http://lorempixel.com/500/249" />
</div>

使用Javascript:

$('.slideshow').slick({
    slide: 'img',
    autoplay: true,
    dots: true,
    dotsClass: 'custom_paging',
    customPaging: function (slider, i) {
        //FYI just have a look at the object to find aviable information
        //press f12 to access the console
        //you could also debug or look in the source
        console.log(slider);
        return (i + 1) + '/' + slider.slideCount;
    }
});

请查看这篇文章以获取更多细节,它还有我从这里获得此代码的小提琴。 Slick.js: Get current and total slides (ie. 3/5)