jQuery.Swiper.js pagination not working, how to setup?

Issue

Slider works but pagination is not visible

HTML:

<div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide">
        <img class="swiper-img" src="/assets/img.png" />
      </div>
      <div class="swiper-slide">
        <img class="swiper-img" src="/assets/img.png" />
      </div>
      <div class="swiper-slide">
        <img class="swiper-img" src="/assets/img.png" />
      </div>
      <div class="swiper-slide">
        <img class="swiper-img" src="/assets/img.png" />
      </div>
    </div>
    <div class="swiper-pagination"></div>

JS:

$(document).ready(() => {
  var swiper = new Swiper(".swiper-container", {
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
          renderBullet: function (index, className) {
            return '<span class="' + className + '">' + "</span>";
          },
        },
      });
    })

enter image description here

The scripts are connected, the slider works. But we see that there is simply no pagination, and it’s not about styles

Solution

You’re using <div class="swiper-pagination"></div> outside the scope of <div class="swiper-container">

Have a look at this code on jsfiddle that I wrote for you:

https://jsfiddle.net/udf82qaw/

Answered By – helloworld

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.