Convert script from Jquery to Vanilla js

I’m in diffulty to transform this script to vanilla js. Can someone help me?

i dont understand

const $this = $(this);
parent() is like parentNode?
.find()?

//

  let swiperInstances = [];
  $(".swiper-container").each(function (index, element) {
    const $this = $(this);
    $this.addClass("instance-" + index);
    $this.parent().find(".swiper-pagination").addClass("pagination-" + index);
    $this.parent().find(".swiper-button-prev").addClass("prev-" + index);
    $this.parent().find(".swiper-button-next").addClass("next-" + index);
    swiperInstances[index] = new Swiper(".instance-" + index, {
      navigation: {
        prevEl: ".prev-" + index,
        nextEl: ".next-" + index,
      }
    });
  });

19 thoughts on “Convert script from Jquery to Vanilla js”

Leave a Comment