I have an element like:
<div style="background-color: #ffffff; background-image: url(image.jpg);></div>
The background properties are being set using jquery like so:
$('div').css('background-color', '#ffffff');
Once the various properties have been set I want to get them all out as a shorthand declaration. I was hoping that just by doing:
var background = $('div').css('background');
would work however it doesnt seem to.
Anybody got a solution to this?
The only thing I can come up with is doing string concatenation such as:
var background = $('div').css('background-color') + ' ' + $('div').css('background-image');
however this will be very messy and rquire a lot of checks as not all background variables are always set, such as position etc.
any thoughts how this can be done would be greatly appreciated!
$('div').css('background')works for me.