var u = ['/img/1.jpg', '/img/2.jpg', '/img/3.jpg']; for(var i in u) document.write('<div style="background-image:url(\''+u[i]+'\')"></div>');