我想每隔3秒改变一次div的背景图片我试过这个没有帮助的人。
它不起作用......
我更新代码:
<head runat="server">
<link rel="shortcut icon" type="icon/x-icon" href="Main Images/favicon.ico" />
<link rel="stylesheet" type="text/css" href="MyStyle.css" />
<script>
accept
var rotate = false;
function setbackground() {
newImage = rotate ? 'url(#)' : 'url(mimages/wallpaper2.jpg) : url(mimages/shutterstock_105126044-795x380.jpg)';
rotate = !rotate;
document.getElementById('change').style.backgroundImage = newImage;
}
setInterval(setbackground, 3000);
</script>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body style="background-image: url('Main Images/background.jpg');">
<form id="form1" runat="server">
<div dir="rtl" style="background-color:#242020">
<audio src="songs/Jurassic Park Theme Song - Jurassic Park Theme Song.mp3" autoplay="" controls=""></audio><br /><br />
</div>
<div class="top" id="change" runat="server" >
答案 0 :(得分:0)
var rotate = false;
function setbackground() {
newImage = rotate ? 'url(mimages/wallpaper2.jpg)' : 'url(mimages/shutterstock_105126044-795x380.jpg)';
rotate = !rotate;
document.getElementById('change').style.backgroundImage = newImage;
}
setInterval(setbackground, 3000);
&#13;
<div class="top" id="change"></div>
&#13;