js 结果不循环怎么回事,不能实现走马灯的效果
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title></title>
<style>
#picture{
height:400px;
width:400px;
line-height: 400px;
margin:0 auto;
overflow: hidden;
}
</style>
</head>
<body onload="setTimeout()">
<div id="picture">
<img src="./1.jpg" id="tu" alt=""/>
</div>
<script type="text/javascript">
var a=['./1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg'];
var i=0;
function huan(){
if(i== a.length-1){
i=0;
}
else{
i++
}
document.getElementById("tu").src=a[i];
setTimeout(huan(),3000);
}
</script>
</body>
</html>