tags:

views:

40

answers:

4

I wanted to do

$('.place').css('background', 'url(open.png) left top no-repeat, url(close.png) bottom right no-repeat');

However jquery doesnt like the ','. Making it two lines has the 2nd css replace the css on the first line. How do i set the css so it will have both open and close background image?

+2  A: 

Having two background images on the same element in CSS is not possible. It is possible with CSS3, but I expect jquery doesn't allow for that yet.

+1  A: 

Use plain javascript instead.

$('.place').get(0).style.background = 'url(open.png) left top no-repeat, url(close.png) bottom right no-repeat'
acidzombie24
+4  A: 

I think it would be easiest to use the addClass(). Since your using css3 i think that would be the only way for you to add it. and just create a css class to add.

Tad
A: 

For your given CSS, jQuery does not do any extra processing. It basically sets:

element.style['background'] = ...;

See lines 33 and 77 in jQuery's source.

A working example of setting 2 backgrounds.

Anurag
How is using jQuery any easier than writing what you just spelled out?
Chase
@Chase - Where exactly did I say anything about jQuery being any easier?
Anurag