var imageUrl = "images/sky.jpg"; $(".div_with_class").css("background-image", "url(" + imageUrl + ")");