首页 > 其他 > 详细

图片切换实例

时间:2016-02-14 01:35:35      阅读:198      评论:0      收藏:0      [点我收藏+]
<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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!