0
我試圖預載圖像庫中的所有圖像,並找到一個很好的,簡單的代碼(第一個代碼示例)。數組內容通過循環?
我想嘗試使畫廊儘可能動態。 有沒有方法循環瀏覽圖庫中的所有圖像,以便可以預加載所有圖像?
首先是預加載所有圖像以供參考的代碼。其次是我正在努力工作。
// code for preloading images
var images = [
'bigPics/1.jpg',
'bigPics/2.jpg'
];
$(images).each(function() {
var image = $('<img />').attr('src', this);
});
。
// code I'm trying to re-work
// this give me the number of images in the gallery
var numberOfChildren = $(".thumb").length;
// then I want to loop through all of the images that make up the array as above and output???
for (var i=0; i<numberOfChildren; i++)
{
var images = [ 'bigPics/' + i + '.jpg' ];
}
$(images).each(function() {
var image = $('<img />').attr('src', this);
});
好一個森達,完美的作品! – user1563944 2012-08-14 21:12:13