繁体   English   中英

Javascript:带有前进/后退按钮的照片库

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM