narusawa narusawa - 7 months ago 10
CSS Question

Is it possible to set backgroud and background image at the same time with javascript?

Whenever I try to set both background and background-image property through javascript, I only get background peroperty on the element. Why is this happening? Did I miss something? = "url('one.png')" = "url('two.png')"

// only gets..

<div style="background-image: url("one.png");">


You can set multiple backgrounds in a single statement: = "url('one.png'), url('two.png')";

In your code, you are overriding one background with the other, as both background and background-image css properties can set a background image.