cat*_*use 0 javascript parameters jquery function
这是一个通过图像旋转的jQuery书籍的示例代码.除了功能(i)部分之外,我理解其中的大部分内容.传递给(i)作为参数的值是什么,当(i)被减去numberOfPhotos时,减去的值究竟是多少?
$(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);
});
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4836 次 |
最近记录: |