cup_of
cup_of

Reputation: 6697

Replace dots with double digit numbers slick slider

Hello I am using the slick slider, I was successful in changing the dots to numbers, but I would like the numbers to be double digit (01, 02, etc). Right now they are single digit (1, 2, etc).

Here is my code for the slick slider:

        jQuery('.slider').slick({
            dots: true,
            customPaging : function(slider, i) {
                var thumb = jQuery(slider.$slides[i]).data();
                return '<a>'+(i+1)+'</a>';
            }

        });

I set up a demo on jsfiddle here

(my js and css come after the minified slick assets)

Thanks

Upvotes: 3

Views: 2996

Answers (1)

MR0
MR0

Reputation: 164

Just modify a little bit your code

    jQuery('.slider').slick({
        dots: true,
        customPaging : function(slider, i) {
            var thumb = jQuery(slider.$slides[i]).data();
            // return '<a>'+(i+1)+'</a>'; // <-- old
            return '<a>'+('0'+(i+1)).slice(-2)+'</a>'; // <-- new
        }

    });

Upvotes: 5

Related Questions