title: Set an Image object as a div background image using javascript
body: <p>I want to load 4 images from background showing a load bar to the client<br/>
  and when the images will be downloaded i want to set them as background images to 4 div blocks.</p>
  
  <p>I am looking for something like this.</p>
  
  <pre><code>var myImages = new Array();
  for(var i = 0; i &lt; 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];
  </code></pre>
  
  <p>Is there any way to set a background image using an Image javascript object?</p>