I work with owl carousel 2 for carousel content.
JS:
$(\'#owl-demo\').owlCarousel({ loop: true, margin: 10, nav: true, items: 1, });
I used this method to solve the problem and I think it's pretty easy.
var options={ margin: 10, nav: true, items: 1 }; if($('#owl-demo .owl-item').length>1){ options.loop=true; } $('#owl-demo').owlCarousel(options);