图片按顺序显示

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
img{
width:100px;
height:100px;
}
</style>
</head>

<body>
<div id="rili"></div>
<script src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function loadImg(arr){
var imgurl=arr.shift();
if(imgurl && typeof imgurl!= 'undefined'){
var img=new Image();
img.src=imgurl;
img.onload=function(){
$("body").append(img)
setTimeout(function(){loadImg(arr)},1000)

}
}

}
loadImg(['timg.jpg','timg1.jpg','timg2.jpg','timg3.jpg','timg4.jpg','timg5.jpg','timg1.png','timg2.png'])
</script></body></html>
posted @ 2019-01-14 10:52  刘浩2561179983  阅读(423)  评论(0编辑  收藏  举报