指引网

当前位置: 主页 > 网页制作 > WEB开发 >

JS数组实现点击下一张

来源:网络 作者:佚名 点击: 时间:2017-07-19 00:31
[摘要] html head meta http-equiv=Content-Type content=text/html; charset=gb2312 meta http-equiv=imagetoolbar content=no titlejs数组实现/title style !-- body{text-align:center;} table{ border:0px; } .sp{ width:520px; height:400px; border:2px solid #FFCC0

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="imagetoolbar" content="no">
<title>js数组实现</title>
<style>
<!--
body{text-align:center;}
table{
 border:0px;
}
.sp{
 width:520px;
 height:400px;
 border:2px solid #FFCC00;
 text-align:center;
 line-height:400px;
}
.sn{
 width:520px;
 height:30px;
 text-align:center;
 line-height:30px;
}
img{
 border:0px; 
 cursor:pointer;
}
-->
</style>
<script language="javascript">
<!--
var photo=new Array(4);
var photoname=new Array(4);


photo[0]="photo/1.jpg"
photoname[0]="柳梦璃"

photo[1]="photo/2.jpg"
photoname[1]="韩菱纱"

photo[2]="photo/3.jpg"
photoname[2]="云天河"

photo[3]="photo/4.jpg"
photoname[3]="慕容紫英"


currid=0

function showphoto(){
currid=currid+1;
if(currid>=4){
currid=0;
}
inphoto.src=photo[currid];
fn.innerHTML=photoname[currid];
}
-->
</script>

</head>
<body>

<table>
 <tr>
  <td class="sp"><img name="inphoto" src="photo/1.jpg" onclick="showphoto()" alt="点击图片显示下一张"></td>
 </tr>
 <tr>
  <td class="sn"><span id="fn">柳梦璃</span></td>
 </tr>
 <tr>
  <td class="sn">JS数组实现点击图片显示下一张</td>
 </tr>
</table>

</body>

</html>

------分隔线----------------------------