0
我格後顯示在鏈中的一個圖像有很多相似圖片一個問題
<div id="gallery">
<img src="images/flowing-rock.jpg" alt="Flowing Rock" width="580" height="360" title="" alt="" />
<img src="images/grass-blades.jpg" alt="Grass Blades" width="580" height="360" title="" alt="" />
<img src="images/ladybug.jpg" alt="Ladybug" width="580" height="360" title="" alt="" />
<img src="images/lightning.jpg" alt="Lightning" width="580" height="360" title="" alt="" />
</div>
我想一次顯示一個圖像和一段時間後,另一圖像將被顯示,但我jQuery代碼不工作。有什麼問題
$(document).ready(function() {
slideShow();
});
function slideShow() {
$('#gallery img').css({ opacity: 0.0 });
$('#gallery img:first').css({ opacity: 1.0 });
setInterval('gallery()', 2000);
}
function gallery() {
var current = ($('#gallery img.show') ? $('#gallery img.show') : $('#gallery img').first());
var next = current.next().length > 0 ? current.next() : $('#gallery img').first();
next.css({ opacity: 0.0 })
.addClass('show')
.animate({ opacity: 1.0 }, 1000);
current.animate({ opacity: 0.0 }, 1000).removeClass('show');
}
任何人都可以請糾正我的代碼。謝謝