A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 迦南 中级黑马   /  2014-9-20 22:04  /  1264 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<style>img{display:none;}
  .btn{border:1px solid black;width:30px;height:30px;display:inline;margin-right:5px;}
</style>
<script type="text/javascript">
  var index=1;//当前显示的图片索引(1-5)
  var timer;
  function switchImg(){
   // 当前这一张隐藏
   document.getElementById("img"+index).style.display="none";   
   
   // 如果当前显示的图片索引没有到最大值就继续增加
   if(index<5){index++;}
   // 否则从第一个图片开始显示,索引从0开始
   else{index=1;}
   // 显示第index张
   document.getElementById("img"+index).style.display="block";

// 下一秒,再执行本方法
   timer = window.setTimeout("switchImg()",10000);
  }

</script>
<body onload="switchImg()">
<!--放五张图,构造一个ImageList-->
<div style="border:0px solid black;width:300px;height:100px;">
<img id="img1" src="images/1.jpg">
<img id="img2" src="images/2.gif">
<img id="img3" src="images/photo_03.jpg">
<img id="img4" src="images/photo_04.jpg">
<img id="img5" src="images/photo_05.jpg">
</div>
<div  id="btn1" onclick="manuImg()"></div>
<div  id="btn2"></div>
<div  id="btn3"></div>
<div id="btn4"></div>
<div id="btn5"></div>
</body>
</html>

1 个回复

倒序浏览
额JS。。。。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马