我是Javascript的新手,并尝试制作一个前后按钮来移动一组图像。我正在做的事情,但它不会工作。我在两个函数的开头都添加了一个警报,它们工作正常,我知道正在调用这些函数。 请帮忙!
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];
}
答案 0 :(得分:1)
可能就像将GetElementById更改为getElementById
一样简单