div背景图片自动切换问题
代码如下:<scriptlanguage="javascript"type="text/javascript">varimages=["images/2.png","im...
代码如下:
<script language="javascript" type="text/javascript">
var images= ["images/2.png", "images/3.png", "images/4.png", "images/5.png"];
var index = 0;
function switch_background(){
if(index ==images_id.length-1)
{
index = 0;
}else{
index++;
}
document.getElementById("div1").style.backgroundImage=url(images[index]);
}
window.onload = function()
{
setInterval(switch_background, 3000);
} </script>
可是添加到html中后起不了作用,谁能告诉我这是怎么回事啊 展开
<script language="javascript" type="text/javascript">
var images= ["images/2.png", "images/3.png", "images/4.png", "images/5.png"];
var index = 0;
function switch_background(){
if(index ==images_id.length-1)
{
index = 0;
}else{
index++;
}
document.getElementById("div1").style.backgroundImage=url(images[index]);
}
window.onload = function()
{
setInterval(switch_background, 3000);
} </script>
可是添加到html中后起不了作用,谁能告诉我这是怎么回事啊 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询