Reputation: 6335
How can one define multiple background images in CSS3 programmatically via JavaScript?
The obvious idea:
var element = document.createElement( 'div' );
element.style.backgroundImage = "url('a.png') 0 100%, url('b.png') 50px 50px ";
doesn't work - it must be something simple, but what?
Upvotes: 2
Views: 4279
Reputation: 97672
backgroundImage
is for background image only if you are setting multiple background properties in one you have to use background
.
element.style.background = "url('a.png') 0 100%, url('b.png') 50px 50px ";
Upvotes: 9