[英]Javascript: Photo Gallery with Forward/Back Button
我是Java語言的超級新手,試圖創建一個前后按鈕來瀏覽一組圖像。以下是我正在做的事情,但這根本行不通。 我在這兩個函數的開頭都添加了警報,並且它們都起作用了,所以我知道這些函數正在被調用。 請幫忙!
HTML:
使用Javascript:
var which=0;
var photos=new Array();
photos[0]='images/gallery/airport.jpg';
photos[1]='images/gallery/vancouvercenter.jpg';
photos[2]='images/gallery/translatorjudges.jpg';
photos[3]='images/gallery/emmaplaying.jpg';
photos[4]='images/gallery/kate.jpg';
photos[5]='images/gallery/plushies.jpg';
photos[6]='images/gallery/juniors.jpg';
photos[7]='images/gallery/pikachucamera.jpg';
photos[8]='images/gallery/dressup.jpg';
photos[9]='images/gallery/sandiego.jpg';
photos[10]='images/gallery/signedbox.jpg';
photos[11]='images/gallery/top42013.jpg';
photos[12]='images/gallery/5.JPG';
photos[13]='images/gallery/airportplay.jpg';
photos[14]='images/gallery/piplup.jpg';
photos[15]='images/gallery/2.JPG';
photos[16]='images/gallery/booze.jpg';
photos[17]='images/gallery/dice.jpg';
photos[18]='images/gallery/akinator.jpg';
photos[19]='images/gallery/sleeping.jpg';
function backward(){
if (which>0){
which=which-1;
}
document.GetElementbyId("gallery").src=photos[which];
}
function forward(){
if (which<photos.length-1)
{
which=which+1;
}
document.GetElementbyId("gallery").src=photos[which];
}
可能就像將GetElementById更改為getElementById一樣簡單
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.