In bxslider i want to add a class on current slide

pixel boon picture pixel boon · Oct 5, 2012 · Viewed 40.7k times · Source

I want to add an extra class to the current visible slide, i dont have so much knowledge of jquery i'm trying it by following code.

 $(document).ready(function(){
     $('#slider1').bxSlider({
        pager: 'true'
     });
 $(currentSlide).addClass('active-slide');
     return false;
 });    

Answer

dariodev picture dariodev · Aug 20, 2013

To add class on the first visible slide you have to call onSliderLoad. Then you continue adding and removing active-slide class with onSlideAfter call.

onSlideAfter: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
    $('.active-slide').removeClass('active-slide');
    $('.bxslider>li').eq(currentSlideHtmlObject + 1).addClass('active-slide')
},
onSliderLoad: function () {
    $('.bxslider>li').eq(1).addClass('active-slide')
},

https://jsfiddle.net/dariodev/587pqsct/