<div id="tupian"></div>
<script>
var jpg =new Array();
jpg[0]="url(c.jpg)";
jpg[1]="url(d.jpg)";
jpg[2]="url(x.jpg)";
jpg[3]="url(z.jpg)";
var tjimg = document.getElementById("tupian");
var xb=0;
function lunbo()
{xb++;
if(xb == jpg.length)
{
xb=0;
}
tjimg.style.backgroundImage=jpg[xb];
window.setTimeout("lunbo()",2000); //实现无限循环图片,即轮播效果
}
window.setTimeout("lunbo()",2000);//调用函数/方法
</script>
时间: 2024-11-10 13:15:16