2个回答
2016-06-05
展开全部
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="div" style="width:100px;height:100px;background-Image:url(b.jpg)"></div>
</body>
<script>
var mydiv = document.getElementById('div');
var imgArray = ['a.jpg', 'b.jpg']
var i = -1;
setInterval(function () {
i++;
i %= imgArray.length;
mydiv.style.backgroundImage = 'url(' + imgArray[i] + ')';
}, 5000);
</script>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询