Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In bxslider i want to add a class on current slide

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;
 });    
like image 941
pixel boon Avatar asked Oct 05 '12 11:10

pixel boon


Video Answer


1 Answers

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/

like image 193
dariodev Avatar answered Oct 30 '22 10:10

dariodev