Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
owlCarousel 2 managed by Data Attribute
// Carousel
if ( jQuery('.owl-carousel').length ) {
jQuery.each( jQuery('.owl-carousel'), function(){
var owlItems = jQuery('.owl-carousel').data('items') ? jQuery('.owl-carousel').data('items') : 3;
owlOptions = [];
if ( typeof jQuery(".owl-carousel").data('items') !== 'undefined' ) owlOptions['items'] = jQuery(".owl-carousel").data('items');
if ( typeof jQuery(".owl-carousel").data('loop') !== 'undefined' ) owlOptions['loop'] = jQuery(".owl-carousel").data('loop');
if ( typeof jQuery(".owl-carousel").data('margin') !== 'undefined' ) owlOptions['margin'] = jQuery(".owl-carousel").data('margin');
if ( typeof jQuery(".owl-carousel").data('nav') !== 'undefined' ) owlOptions['nav'] = jQuery(".owl-carousel").data('nav');
if ( typeof jQuery(".owl-carousel").data('dots') !== 'undefined' ) owlOptions['dots'] = jQuery(".owl-carousel").data('dots');
if ( typeof jQuery(".owl-carousel").data('autoplay') !== 'undefined' ) owlOptions['autoplay'] = jQuery(".owl-carousel").data('autoplay');
if ( typeof jQuery(".owl-carousel").data('autoplay-timeout') !== 'undefined' ) owlOptions['owlAutoplayTimeout'] = jQuery(".owl-carousel").data('autoplay-timeout');
var $carousel = jQuery(this);
$carousel.owlCarousel(owlOptions);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.