Cody Raspien Cody Raspien - 1 month ago 15
HTML Question

syntax error - JS - background.style.backgroundImage

This works and the image renders.

body.style.backgroundImage = 'url(0.gif)';


This does not work and the image does not render at all.

body.style.backgroundImage = 'url(0.gif) no-repeat center center fixed';


There is no error in the console.

What am I missing here? This should have worked. The second is syntactically correct, right?

Answer

Use body.style.background instead. The body.style.backgroundImage is just for the image.

Comments