Your CSS that you're trying to apply to the
div
is the part that's wrong. Basically what you're doing, in CSS, is this:
div {
background-image: url(img) repeat;
}
That is incorrect. You can only specify the
background image when using the
background-image
property. You were specifying the image
and the repeating behavior. This is invalid CSS.
Your CSS code should be:
div {
background-image: url(img);
background-repeat: repeat;
}
And therefore your Javascript:
var div = document.getElementById("div-id");
div.style.backgroundImage = "url(img)";
div.style.backgroundRepeat = "repeat";
You can alternatively use the shorthand syntax but that should solve your problem.