このスライドショー スクリプトをセットアップして、表示される最初の写真がランダムになるようにしようとしています (サイトにアクセスするたびに、最初の写真を異なる/ランダムなスライドにする必要があります)。残りの写真は正しい順序で表示できます。それはいいです。
Jon Raasch のシンプルな jquery スライドショー スクリプトを使用しています。
<script type="text/javascript">
function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
var $next = $active.next().length ? $active.next()
: $('#slideshow DIV:first');
$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()", 2500 );
});
</script>
<div id="slideshow">
<div class="active"><img src="images/slide1.jpg"></div>
<div><img src="images/slide2.jpg"></div>
<div><img src="images/slide3.jpg"></div>
<div><img src="images/slide4.jpg"></div>
<div><img src="images/slide5.jpg"></div>
</div>
そしてCSS:
#slideshow {
position:relative;
height:401px;
}
#slideshow div {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow div.active {
z-index:10;
opacity:1.0;
}
#slideshow div.last-active {
z-index:9;
}
私はいくつかのことを試しましたが、javascript は本当に私のお茶ではなく (ここでは「デザイナーの心」)、私が試したことがうまくいきません。何か案は?
本当にありがとう!