src属性替换图片,
程序代码:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <script> var ImageArray=new Array("1.jpg","2.jpg","3.jpg"); var index=0; function nextImage() { index++; if(index<ImageArray.length) document.images[image1].src=ImageArray[index]; else { index=0; document.images[image1].src=ImageArray[index]; } } function lastImage() { index--; if(index<0) index=-1; if(index<ImageArray.length) document.images[image1].src=ImageArray[index]; else { index=0; document.images[image1].src=ImageArray[index]; } } </script> <body> <img src="1.jpg" name="image1" id="image1"width=500 height=500> <a href="JavaScript:nextImage()">下一张</a> <a href="JavaScript:lastImage()">上一张</a> </body> </html>
点击链接没反应