I have a <div> transparency of its background color (and not its contents) that I would like to change. The remote API sends me this color:
and I will tell jQuery (1.9) to apply this color via .css :
$('div').css('background-color', '#abcdef');
The resulting div has a background-color style of not #abcdef , but rather its RGB representation of the same color.
background-color: rgb(171, 205, 239);
(Just observation, not part of the problem)
The requirement for the project has been changed in such a way that now I will also need to change the transparency of the background to the set percentage (50%). So my desired background-color attribute
background-color: rgba(171, 205, 239, 0.5);
however, I cannot find a way to set this background-color attribute using only jQuery, a hexadecimal color code, and still apply an alpha value. opacity affects the contents of the div as well as the background, so this is not an option.
$('div').css('background-color', '#abcdef') .css('opacity', 0.5);
Given the line #abcdef , is it only possible to calculate (e.g. hex2dec) that I can apply the opacity of the background to the div if I only get the hex color string?