narusawa narusawa - 1 year ago 49
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");">

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download