假設幻燈片功能看起來有點像這樣:
function slideShow() {
var slideShowImages = new Array();
slideShow.prototype.load = function(img){ /*loads img into array*/ };
slideShow.prototype.start = function(){ /*starts the slideshow*/ };
slideShow.prototype.stop = function() { /*stops slideshow*/ };
slideShow.prototype.empty = function() { /*empties array*/ };
};
爲了確保您只顯示某一車輛的圖像將它們放置在一個數組:
var airplanes = new Array();
var cars = new Array();
var boats = new Array();
然後,當裝載所有圖像,將它們放在正確的陣列中:
var boatImg = new Image();
boatImg.src = theSourceOfImage;
boatImg.addEventListener('load', function() { boats.push(boatImg) });
//etc etc.
將點擊處理程序附加到拇指指甲。
SlideShow = new slideShow();
$("#boatThumbNailId").click(function() {
//now place all of the pictures from the boat array in the slideshow
for(var i = 0; i < boats.length; i++)
SlideShow.load(boats[i]);
//then just start the slideShow
SlideShow.start();
});
我希望這會對你有所幫助,祝你好運。
你能告訴我們你已經試過了嗎? –
@MaxLangerak我編輯我的文章,請看看它...對不起英語 –