J'ai this diaporama jquery basé et fonctionne très bien, l'auteur a même mis dans un paramètre de randomisation qui est ce dont j'avais besoin. Cela fonctionne très bien sauf qu'il ne randomise pas la première diapositive. Des idées? Merci :)Randomiser la première image de ce diaporama?
Voici les js: (ou aller à la original page pour plus d'informations)
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>
'Essayez var $ SIBS = $ active.siblings() andSelf()' pour sélectionner tous les éléments. Je ne sais pas si c'est le problème. –