<script type="text/javascript">
var currentIndex = 0;
function changeBg() {
//定义要切换的背景图片,双引号里面"1.jpg","2.jpg","3.jpg","4.jpg",可以放任意多个用,隔开
var bgImgs = ["1.jpg","2.jpg","3.jpg","4.jpg"];
if (currentIndex >= bgImgs.length)
currentIndex = 0;
$("#divbanner").css("background-image", "url(" + bgImgs[currentIndex] + ")");
currentIndex += 1;
}
setInterval("changeBg()", 2000); //设定定时切换,单位为毫秒这里是3000 毫秒
</script>
<div id="divbanner" class="banner" style="background-image:url(<%= strhomeAdvertisement_1%>);">
</div>
var currentIndex = 0;
function changeBg() {
//定义要切换的背景图片,双引号里面"1.jpg","2.jpg","3.jpg","4.jpg",可以放任意多个用,隔开
var bgImgs = ["1.jpg","2.jpg","3.jpg","4.jpg"];
if (currentIndex >= bgImgs.length)
currentIndex = 0;
$("#divbanner").css("background-image", "url(" + bgImgs[currentIndex] + ")");
currentIndex += 1;
}
setInterval("changeBg()", 2000); //设定定时切换,单位为毫秒这里是3000 毫秒
</script>
<div id="divbanner" class="banner" style="background-image:url(<%= strhomeAdvertisement_1%>);">
</div>