<html>
<head>
	<meta http-equiv="content-type" content="text/html" charset="UTF-8">
	<script type="text/javascript" >
			var picArr=new Array("1.jpg","2.jpg","3.jpg")	;
			var index=0;
			//展示下一张图片
			function next(){
					index++;
					if (index==picArr.length){
							index=0;
					}
					document.getElementById("img1").src=picArr[index];
			}
			//展示上一张图片
			function precious(){
					index--;
					if (index<0){
							index=picArr.length-1;
					}
					document.getElementById("img1").src=picArr[index];
			
			}
	</script>
	<body>
			<img id="img1"src="1.jpg" width="500" height="300"/><br/>
			<input type="button" value="下一张" onclick="next()"/>
			<input type="button" value="上一张" onclick="precious()"/>
	<body>
	</html>
原文:http://www.cnblogs.com/sosomark/p/5188500.html