how to change the background image of div using javascript?
try this one!
var el = document.getElementById("a").style.backgroundImage;
if(el == "url(Black-Wallpaper.jpg)") { // full value is provided
el.style.backgroundImage = "url(/link/to_new_file.png)"; // change it
}
Try this:
document.getElementById('a').style.backgroundImage="url(images/img.jpg)"; // specify the image path here
Hope it helps!