bx slider : how to disable slide show when only one image is present

孤人 提交于 2019-12-03 08:06:42

You should check the number of images before reloading, and use destroySlider() method if there is only 1 image.

// Get the quantity of images (add your code if you want an example)
var numberOfImages = ...;

if (numberOfImages > 1) {
    coverSlider.reloadSlider();
} else {
    coverSlider.destroySlider();
}

this helps me:

$(document).ready(function(){
  $('.bxslider').bxSlider({
    mode: 'fade',
    auto: ($(".bxslider li").length > 1) ? true: false,
    pager: ($(".bxslider li").length > 1) ? true: false,
    controls: false
  });
});

Try

var numImgs = $('div.myClassName img').length;
if(numImgs>1)
{
\\Do your bxslider reload here
}

Instead you can use Jquery Selector too like below

jQuery(".image").Length

Hope this helps...

Click here to read about selectors Click

var numImgs = $('div.bxslider img').length;
if (numImgs > 1) {
    $('.bxslider ').bxSlider({
        controls: true,
        ...
    });
}

This solution works for me Change auto: true to

    auto: ($('#slidername').children().length < 2) ? false : true    

Thanks to https://github.com/stevenwanderski/bxslider-4/issues/607

bx slider : how to disable slide show when only one image is present?

Set auto to false:

   var coverSlider = $('.bxslider').bxSlider({
        auto:false
   })
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!