add background image to div using jquery

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

Also in JavaScript: