본문 바로가기
jquery

[bxslider.js] current / total 뽑아내고 css 적용하기

by 바나냥 2020. 4. 4.
var mainSlider = $('.mainSlide > .slider').bxSlider({
  auto: true,
  pager: false,
  controls: false,
  infiniteLoop: true,
  onSliderLoad: function (currentIndex){
  	$('#slide-counter .current').text(currentIndex + 1);
  },
  onSlideBefore: function ($slideElement, oldIndex, newIndex){
  	$('#slide-counter .current').text(newIndex + 1);
  }
});
$('#slide-counter').append(mainSlider.getSlideCount());
//혹은
$('#slide-counter .total').text(mainSlider.getSlideCount());


<div id="slide-counter"><span class="current"></span> / <span class="total"></span></div>

댓글