請易 - 第一篇文章!提前幻燈片手動與jQuery
展望修改下面的腳本: http://jonraasch.com/blog/a-simple-jquery-slideshow
愛它的簡單,試圖找到一種方式來增加提前功能
最好的IMG或DIV - 上點擊或鏈接。
有什麼建議嗎?
欣賞的幫助
編輯,下面是腳本,這裏是一個工作版本的鏈接:
腳本:
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ($active.length == 0) $active = $('#slideshow IMG:last');
// use this to pull the images in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
// uncomment the 3 lines below to pull the images in random order
// 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()", 5000);
});
風格:
#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
HTML:
<div id="slideshow">
<img src="image01.jpg" width="262" height="496" border="0" class="active" />
<img src="image02.jpg" width="262" height="496" border="0" />
</div>
謝謝sg3s。我用上面的代碼試過了jquery代碼,它不會提前也不會循環播放幻燈片 – jsheps
嘗試對它進行一些基本的調試。你可以看到更多的僞代碼,你沒有發佈你現在使用的代碼(html + images,css,javascript),所以我不能告訴你如何整合它。 – sg3s
易老虎!這是我第一次:)。我使用我正在使用的代碼編輯了我的帖子。也許這將有助於?感謝您試用它! – jsheps