js图片自动轮播代码分享(js图片轮播)(2)

function move(index) {
    //document.title = index;
    if(index>aLi.length-1) {
     index = 0;
     iNow = index;
    }
    if(index<0) {
     index = aLi.length - 1;
     iNow = index;
    }
    for(var n=0;n<aBtn.length;n++) {
     aBtn[n].className = ""; 
    }
    aBtn[index].className = "active";
    oUl[0].style.left = -index * baseWidth + "px";
    //buffer(oUl[0],{
    // left: -index * baseWidth
    // },8)

   }
  }
  </script>
  </head>
<body>
 <div>
  <a href="javascript:void(0);" ></a>
  <a href="javascript:void(0);" ></a>
  <!--when change next image:style="left: -(n-1)*800px;"-->
  <ul>
   <li><img src="https://www.jb51.net/article/1.jpg" alt="" /></li>
   <li><img src="https://www.jb51.net/article/2.jpg" alt="" /></li>
   <li><img src="https://www.jb51.net/article/3.jpg" alt="" /></li>
   <li><img src="https://www.jb51.net/article/4.jpg" alt="" /></li>
   <li><img src="https://www.jb51.net/article/5.jpg" alt="" /></li>
   <li><img src="https://www.jb51.net/article/6.jpg" alt="" /></li>
  </ul>
  <div> 
   <a href="javascript:void(0);"></a>
   <a href="javascript:void(0);"></a>
   <a href="javascript:void(0);"></a>
   <a href="javascript:void(0);"></a>
   <a href="javascript:void(0);"></a>
   <a href="javascript:void(0);"></a>
  </div>
 </div>
</body>
</html>

图片自动播放.html

复制代码 代码如下:


<!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=utf-8" />
  <title>images</title>
 <script type="text/javascript">
  var curIndex = 0;
  var timeInterval = 1000;
  var arr = new Array();
  arr[0] = "https://www.jb51.net/article/1.jpg";
  arr[1] = "https://www.jb51.net/article/2.jpg";
  arr[2] = "https://www.jb51.net/article/3.jpg";
  arr[3] = "https://www.jb51.net/article/4.jpg";
  arr[4] = "https://www.jb51.net/article/5.jpg";
  arr[5] = "https://www.jb51.net/article/6.jpg";
  arr[6] = "7.jpg";
  setInterval(changeImg,timeInterval);
  function changeImg() {
   var obj = document.getElementById("obj");
   if (curIndex == arr.length-1) {
    curIndex = 0;
   } else {
    curIndex += 1;
     }
   obj.src = arr[curIndex];
  }
 </script>

 <!-- <script language="javascript">
  setInterval(test,1000);
  var array = new Array();
  var index = 0;
  var array = new Array("image/1.jpg","image/2.jpg","image/3.jpg","image/4.jpg","image/5.jpg","image/6.jpg","image/7.jpg","image/8.jpg","image/9.jpg","image/10.jpg");
  function test() {
   var myimg=document.getElementById("imgs");
   if(index==array.length-1)
   { index=0; }else{ index++; }
   myimg.src=array[index];
  }
 </script> -->
 </head>
 <body>
  <img id = "obj" src = "https://www.jb51.net/article/1.jpg" border = 0 />
 </body>
</html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgpsxy.html