I've got this jquery-based slideshow up and running just fine, the author even put in a randomization setting which is what I needed. It works great except that it doesn't randomize the first slide. Any ideas? Thanks:)
Here's the js: (or go to the original page for more info)
function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
// use this to pull the divs in the order they appear in the markup
// var $next = $active.next().length ? $active.next()
// : $('#slideshow DIV:first');
// uncomment below to pull the divs randomly
var $sibs = $active.siblings();
var rndNum = Math.floor(Math.random() * $sibs.length );
var $next = $( $sibs[ rndNum ] );
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 20000 );
});
HTML:
<div id="slideshow">
<div class="active">
<img src="img/img1.jpg" />
</div>
<div>
<img src="img/img2.jpg" />
</div>
<div>
<img src="img/img3.jpg" />
</div>
</div>
'
^That randomizes the first loaded image on page load with img1.jpg, img2.jpg, and img3.jpg, so combined with the javascript randomizing after the first image has been loaded, you end up with full ranomization :). Dirty, but it works for me.