在一个网页中,body中有背景,想在页面的div框中加上图片的自动变换,怎么弄啊,请教!!!!!拜托。
------解决方案--------------------
- HTML code
<html> <head> <script> var aaa=['1.png','2.png','3.png']; var count = 0; function on_load(){ document.body.style.background="url("+aaa[count]+")"; if (++count == aaa.length) { count = 0; } } setInterval("on_load()",1000); </script> </head> <body> </body> <html>
------解决方案--------------------
document.body.style.background="url("+aaa[count]+")";
改成
document.getElementById("div的id").style.background="url("+aaa[count]+")";