我想要在后台加载4张图片,向客户端显示加载条,并在下载完成后将它们设置为4个div块的背景图像。
我正在寻找类似于此的东西。
var myImages = new Array();
for(var i = 0; i < 4; i++)
myImages[i] = new Image();
//load images using the src attribute
//and execute an on load event function where to do something like this.
var div0 = document.getElementById('theDivId');
div0.style.backgroundImage = myImage[index];
有没有办法使用JavaScript中的Image对象设置背景图片?