Thursday, 15 January 2015

Define owl carousel parameters in HTML (with class or data attribute) -



Define owl carousel parameters in HTML (with class or data attribute) -

i have page few owl carousels. able set parameters these owl carousels in html code (using class or info attribute).

assuming have 2 info attributes defined in html, have created next jquery code:

$(".owl-carousel").each(function( index ) { var items_no = $(this).data('slides'); var autoplay = $(this).data('autoplay'); $(".owl-carousel").owlcarousel({ items : items_no, autoplay: autoplay }); });

and may expect not working. parameters first owl carousel applied carousels. have no thought how create work. below fiddle attempt.

http://jsfiddle.net/t2gj8eg2/4/

i grateful able prepare me. in advance

should be:

$(".owl-carousel").each(function (index) { var items_no = $(this).data('slides'); var autoplay = $(this).data('autoplay'); $(this).owlcarousel({ // utilize $(this) items: items_no, autoplay: autoplay }); });

html owl-carousel

No comments:

Post a Comment