I'm trying to setup a slideshow to use data attributes for setting the timeout on each slide. This works for jQuery Cycle, but not for jQuery Cycle 2. I think I might be using the wrong function, but didn't find anything similar in the Cycle 2 docs?
HTML:
<div id="slides">
<img src="img1.jpg" data-duration="1000" />
<img src="img2.jpg" data-duration="2000" />
<img src="img3.jpg" data-duration="3000" />
</div>
JS:
$('#slides').cycle({
fx: 'fadeout',
speed: 250,
timeoutFn: function(currElement, nextElement, opts, isForward) {
return parseInt($(currElement).attr('data-duration'), 10);
}
});
Cycle2 supports that directly. Use data-cycle-timeout
attributes on the slides instead of data-duration
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With