JS图片自动切换

<!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>图片自动跳转</title>

<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="imgs" src="image/1.jpg" /> </body>

</html>

posted @ 2013-05-07 00:27  I can play  阅读(583)  评论(6编辑  收藏  举报