I want to add and an extra class on 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;
});
http://bxslider.com/options
var slider=$('#slider1').bxSlider({
pager: 'true',
onBeforeSlide: function(currentSlide, totalSlides, currentSlideHtmlObject){
$('.pager').removeClass('active-slide');
$(currentSlideHtmlObject).addClass('active-slide');
// $('#sddf').html('<p class="check">Slide index ' + currentSlide + ' of ' + totalSlides + ' total slides has completed.');
}
});
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/
Here it is:
$('#slider1 ul').bxSlider({
pager: 'true',
onSliderLoad: function(currentIndex) {
$('#slider1').find('.bx-viewport').find('ul').children().eq(currentIndex + 1).addClass('active-slide');
},
onSlideBefore: function($slideElement){
$('#slider1').find('.bx-viewport').find('ul').children().removeClass('active-slide');
$slideElement.addClass('active-slide');
}
});
JSFiddle
its 100% working
$(document).ready(function(){
$('.bxslider1').bxSlider({
slideWidth: 280,
slideMargin: 20,
useCSS: false,
autoHover: false,
speed: 2000,
oneToOneTouch: true,
pager: 'true',
onSliderLoad: function(currentIndex) {
$('.bxslider1').find('.bx-viewport').find('ul').children().eq(currentIndex + 1).addClass('active-slide');
},
onSlideBefore: function($slideElement){
$('.bxslider1').find('.bx-viewport').find('ul').children().removeClass('active-slide');
$slideElement.addClass('active-slide');
}
});
});