js 怎么改变在几张图片比如说三张作为body的背景图片然后利用这三张图片轮流作为body的背景色

如题所述

js 切换body的背景
在images中添加1.jpg 2.jpg 3.jpg 三张图片就好了

<html>
<head>
<title> New Document </title>
</head>
<body>
</body>
</html>
<script type="text/javascript">
function qiehuan(i){
var n = i;
if(n>3)
n=1;
var bg = document.body||document.documentElement;
bg.style.background = "url('images/"+n+".jpg')";
n++;
setTimeout("qiehuan("+n+")",1000); //1秒轮换一张 2000为两秒
}
qiehuan(1);
</script>来自:求助得到的回答
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答