這是一個jQuery書籍中通過圖像旋轉的示例代碼。除了說函數(i)的部分之外,我對它的大部分理解。 (i)作爲參數傳遞什麼價值?當(i)被減去numberOfPhotos時,究竟是什麼值被減去?函數(i)在這個jQuery代碼中意味着什麼?
$(document).ready(function(){
rotatePics(1);
});
function rotatePics(currentPhoto) {
var numberOfPhotos = $('#photos img').length;
currentPhoto = currentPhoto % numberOfPhotos;
$('#photos img').eq(currentPhoto).fadeOut(function() {
$('#photos img').each(function(i) {
$(this).css(
'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
);
});
$(this).show();
setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
});
}
我明白了,謝謝! – catandmouse