How to add pagination in slider?

Add pagination to the slider code
if ( 0 < ( this.maxImages - ( this.slider.parent().width() / this.slider.find(".slide").width() ) )) {
 this.slider.parent().append('<div class="slider-btn previous"></div><div class="slider-btn next"></div><div class="slider-pagination"></div>');
 this.slider.siblings(".slide").foreach(function () {
 this.slider.siblings(".slider-pagination").append('<div class="slider-points"></div>');
});
 }

.slider-point is not added. How to add the number of points in .slider-pagination the number of slides in .slider?

Full code:
March 23rd 20 at 18:52
1 answer
March 23rd 20 at 18:54
Solution
const
 count = this.slider.find('.slide').length,
 html = Array(count).fill('<div class="slider-points"></div>').join(");

this.slider.siblings('.slider-pagination').append(html);
Thank you. Point added. Tell me how to set them to the function? Written:
this.nextImage = this.nextImage.bind(this);

 this.sliderPoint = this.slider.siblings(".slider-point");
 this.sliderPoint.on("click", this.nextImage);


previousImage() {
 this.currentImg = Math.max(this.currentImg - 1, 0);
 this.scrollImages(this.currentImg, this.speed);
}

Nothing happens. - adriel_Ort commented on March 23rd 20 at 18:57
@adriel_Ort,

You somehow think if the siblings - it's such a magical thing that will find any desired objects. This is not so. Open the documentation and see what it does. Then look at your markup. Think and realize their mistakes.

What to switch slides on the points - why are you trying to do this using the method nextImage? It should be a transition to a particular slide and not relative to the current. You need to write a corresponding method for receiving the slide number and scrolls to it. - Augusta.Legr commented on March 23rd 20 at 19:00
@Augusta.Legr, nextImage for example. - adriel_Ort commented on March 23rd 20 at 19:03
@adriel_Ort, then what? - Augusta.Legr commented on March 23rd 20 at 19:06
@Augusta.Legrthat? - adriel_Ort commented on March 23rd 20 at 19:09

Find more questions by tags JavaScript