How to randomize initial image with jquery-cycle plugin
After searching for a solution to show a random image from the sequence using jquery-cycle, I found this post with a simple (undocumented) solution.
Just add the following line to your cycle function, replacing 4 with the total number of slides:
[code lang=”js”]startingSlide: Math.floor(Math.random()*4)[/code]
Any idea how to randomize the initial image in jQuery Cycle2?
Try this
var k=$(‘#pic > div’).length;
$(‘#pic’).cycle({
next: ‘#next’,
startingSlide: Math.floor(Math.random()*k)
});