所以...我从数组中获取图像,设置时间间隔的问题,以便轮流显示图像
$(function() {
var length = $('.fadein img').length; //get the number of images
var arrayimage = [];
for (i=0; i<length; i++){ // fill the array
arrayimage.push($(".fadein img:eq("+ i +")").attr("src"));
}
var lengtharray = arrayimage.length;
setTimeout(function run() {
for (i=0; i<lengtharray; i++){ //get images by turn
var cft = arrayimage[i];
var imageurl = cft;
$("html").css({
'background': '#000000 url("' +imageurl + '") no-repeat top left fixed',
'background-size' : 'cover',
'width':'100%',
'height':'100%',
'position':'avsolute'
});
setTimeout(cft, 5000);
alert("set");
}
},5000);
});
如何设置间隔?如有必要,它是 html 代码:)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style.css" rel="stylesheet" type="text/css">
<script src="js/jquery/jquery2.0.3.js"></script>
<script src="js/jquery/slideshow.js"></script>
</head>
<body>
<div class="fadein">
<img src="images/backgrounds/stones.jpg"/>
<img src="images/backgrounds/pier.jpg"/>
<img src="images/backgrounds/sea-mist.jpg"/>
<img src="images/backgrounds/mojave.jpg"/>
<img src="images/backgrounds/flowing-rock.jpg"/>
</div>
</body>
</html>