Если несколько слайдеров на одной странице сайта
HTML
<div class="slider-item">
<div class="slider-cont">
<div class="object-slider swiper" id="slider-1">
<div class="swiper-wrapper">
<div class="swiper-slide">1</div>
<div class="swiper-slide">2</div>
<div class="swiper-slide">3</div>
</div>
<div class="swiper-pagination"></div>
</div>
<div class="slider-nav-item slider-prev" id="slider-1-prev"></div>
<div class="slider-nav-item slider-next" id="slider-1-next"></div>
</div>
</div>
<div class="slider-item">
<div class="slider-cont">
<div class="object-slider swiper" id="slider-2">
<div class="swiper-wrapper">
<div class="swiper-slide">1</div>
<div class="swiper-slide">2</div>
<div class="swiper-slide">3</div>
</div>
<div class="swiper-pagination"></div>
</div>
<div class="slider-nav-item slider-prev" id="slider-2-prev"></div>
<div class="slider-nav-item slider-next" id="slider-2-next"></div>
</div>
</div>
JS
//слайдер
var swiper_list = $(".object-slider");
$(swiper_list).each(function() {
let swiper_slider_id = $(this).attr('id');
var swiper = new Swiper("#" + swiper_slider_id, {
slidesPerView: 1,
spaceBetween: 15,
loop: true,
pagination: {
el: "#" + swiper_slider_id + " .swiper-pagination",
type: "fraction",
},
navigation: {
prevEl: "#" + swiper_slider_id + "-prev",
nextEl: "#" + swiper_slider_id + "-next",
},
});
});
//слайдер