1

我是 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];
    }
4

1 回答 1

1

可能就像将 GetElementById 更改为 getElementById 一样简单

于 2013-10-22T01:19:55.873 回答